블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Script (91)
Extensions (14)
Effect (3)
NGUI (77)
UGUI (8)
Physics (2)
Shader (36)
Math (1)
Design Pattern (2)
Xml (1)
Tips (200)
Link (22)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (70)
Trouble Shooting (68)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (8)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (11)
Ad (14)
Photon (2)
IAP (1)
Google (8)
Android (45)
iOS (41)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-26 17:51

Hidden Assets

During the import process, Unity ignores the following files and folders in the Assets folder (or a sub-folder within it):

  • Hidden folders.
  • Files and folders which start with ‘.’.
  • Files and folders which end with ‘~’.
  • Files and folders named cvs.
  • Files with the extension .tmp.

This prevents importing special and temporary files created by the operating system or other applications.

 

[출처] https://forum.unity.com/threads/exclude-files-or-folders-from-importing.48090/

 

Exclude files or folders from importing

Is there any way to exclude psd, jpg, max file (or whole folder) in Assets folder from being imported to Unity as texture or model? I keep my...

forum.unity.com

 

[참조] https://docs.unity3d.com/Manual/SpecialFolders.html?_gl=1*f8onwh*_ga*MTUzMjkzMTA0MC4xNjIyNzEzNDM4*_ga_1S78EFL1W5*MTYyNDg3MTc4MS41LjEuMTYyNDg3MjE4OC4xMA..&_ga=2.190280226.821848530.1624841162-1532931040.1622713438 

 

Unity - Manual: Special folder names

Reusing assets between projects How do you use documentation throughout your workflow? Share your experience with us by taking this survey. Special folder names You can usually choose any name you like for the folders you create to organise your Unity proj

docs.unity3d.com

 

반응형
Posted by blueasa
, |

[Android 앱 이름 로컬라이징] chameleonstudio.tistory.com/51

 

유니티 구글 앱 이름 변경 / 현지화

해당 티스토리 페이지는 필자가 유니티 C# 개발을 하면서 학습한 내용들을 기록하고 공유하는 페이지입니다 ! - 틀린 부분이 있거나, 수정된 부분이 있다면 댓글로 알려주세요 ! - 해당 내용을 공

chameleonstudio.tistory.com

 

 

[iOS 앱 이름 로컬라이징] chameleonstudio.tistory.com/52

 

iOS 앱 이름 변경 / 현지화

해당 티스토리 페이지는 필자가 유니티 C# 개발을 하면서 학습한 내용들을 기록하고 공유하는 페이지입니다 ! - 틀린 부분이 있거나, 수정된 부분이 있다면 댓글로 알려주세요 ! - 해당 내용을 공

chameleonstudio.tistory.com

 

반응형
Posted by blueasa
, |

화면 색상이 이상한 경우 참고하실만한 내용인거 같습니다.

 

겔럭시 S10이상의 폰에서 게임 화면이 하얗게 나오는 현상이 발생합니다.

이 경우 원인은 옵션에서 사용자가 고르는 화면 모드가 원인입니다.

 

옵션 -> 디스플레이 -> 화면 모드를 선택합니다.

 

여기에서 선명한 화면을 선택 해봅시다.

 

정상적으로 색상이 돌아온것을 확인할 수 있습니다.

 

 

[출처]

gamecodi.com/4145/%EA%B2%94%EB%9F%AD%EC%8B%9C-s10%EC%9D%B4%EC%83%81%EC%9D%98-%ED%8F%B0%EC%97%90%EC%84%9C-%EA%B2%8C%EC%9E%84%ED%99%94%EB%A9%B4%EC%9D%B4-%ED%95%98%EC%96%97%EA%B2%8C-%EB%82%98%EC%98%A4%EB%8A%94-%ED%98%84%EC%83%81

 

겔럭시 S10이상의 폰에서 게임화면이 하얗게 나오는 현상 - 게임코디

화면 색상이 이상한 경우 참고하실만한 내용인거 같습니다. 겔럭시 S10이상의 폰에서 게임 화면이 하얗게 나오는 현상이 발생합니다. 이 경우 원인은 옵션에서 사용자가 고르는 화면 모드가 원

gamecodi.com

 

반응형
Posted by blueasa
, |

UnityでiOSとAndrodのランタイムパーミッションの確認と要求を行う方法

 

Unityでアプリのカメラ権限の確認&要求ってどうやるの?

これまでのUnityでのアプリ開発では、iOS/Android端末の機能の権限のチェックやリクエストをするために、ネイティブプラグインを利用する必要がありました。
最近になってやっと、ランタイムパーミッション関係のAPIが追加されたようなので、自分なりに使い方を調べてみました。


[iOS] Application.RequestUserAuthorizationクラス

https://docs.unity3d.com/ja/2018.2/ScriptReference/Application.RequestUserAuthorization.html
Unity2018.1以降で利用可能
iOSでウェブカメラまたはマイクを使用するための承認をリクエストします。
(カメラとマイクの権限のみチェックとリクエストが可能)

[Android] Android.Permissionクラス

https://docs.unity3d.com/2018.3/Documentation/ScriptReference/Android.Permission.RequestUserPermission.html
https://docs.unity3d.com/ja/current/Manual/android-RequestingPermissions.html
Unity2018.3以降で利用可能
Androidでユーザーに、デバイスリソースまたは承認が必要な情報へのアクセスを許可するよう要求します。
(クラスで定義されていない権限でも文字列で指定してチェックとリクエストが可能)


それぞれのプラットフォームに対応している新しく追加されたAPIを使用することで、簡易的な処理ならばネイティブプラグインを使用しないで目的を達成できそうです。
今回はカメラとマイクの権限の確認と要求をセットで行う例の作成を試みました。
そして、何回も試行錯誤した結果、導きだしたコードがこちら。

ランタイムパーミッション要求の例

using UnityEngine;
using System.Collections;
using System;

#if UNITY_ANDROID && UNITY_2018_3_OR_NEWER
using UnityEngine.Android;
#endif

namespace PermissionAuthorizationTest
{
    // iOS/Androidプラットフォームで動作するランタイムパーミッション要求のサンプル
    // 参考URL: https://forum.unity.com/threads/requestuserauthorization-as-a-coroutine-bugged.380666/
    public class PermissionAuthorizationExample : MonoBehaviour
    {
        IEnumerator Start ()
        {
            #if UNITY_IOS && UNITY_2018_1_OR_NEWER

            // iOS
            //
            // カメラパーミッションが許可されているか調べる
            if (!Application.HasUserAuthorization (UserAuthorization.WebCam)) {
                // 権限が無いので、カメラパーミッションのリクエストをする
                yield return RequestUserAuthorization (UserAuthorization.WebCam);
            }
            // マイクパーミッションが許可されているか調べる
            if (!Application.HasUserAuthorization (UserAuthorization.Microphone)) {
                // 権限が無いので、マイクパーミッションのリクエストをする
                yield return RequestUserAuthorization (UserAuthorization.Microphone);
            }
            // リクエストの結果、アプリ機能に必要なパーミッションが全て許可されたか調べる
            if (Application.HasUserAuthorization (UserAuthorization.WebCam) && Application.HasUserAuthorization (UserAuthorization.Microphone)) {
                // 権限が許可されたので、権限が必要なAPIを使用する処理へ進む(iOSでは権限拒否された状態でAPIを使用しようとするとアプリが落ちる)
                findWebCams ();
                findMicrophones ();
            } else {
                // 権限が許可されなかったので、ユーザーに対して権限の使用用途の説明を表示して自分でOSのアプリ設定画面で権限許可を行うようにアナウンスする必要がある。
                // (iOSでは初回の権限リクエストが拒否された場合は、次回からはリクエスト自体が表示されなくなる)
            }       

            #elif UNITY_ANDROID && UNITY_2018_3_OR_NEWER

            // Android
            //
            // カメラパーミッションが許可されているか調べる
            if (!Permission.HasUserAuthorizedPermission (Permission.Camera)) {
                // 権限が無いので、カメラパーミッションのリクエストをする
                yield return RequestUserPermission (Permission.Camera);
            }
            // マイクパーミッションが許可されているか調べる
            if (!Permission.HasUserAuthorizedPermission (Permission.Microphone)) {
                // 権限が無いので、マイクパーミッションのリクエストをする
                yield return RequestUserPermission (Permission.Microphone);
            }
            // リクエストの結果、アプリ機能に必要なパーミッションが全て許可されたか調べる
            if (Permission.HasUserAuthorizedPermission (Permission.Camera) && Permission.HasUserAuthorizedPermission (Permission.Microphone)) {
                // 権限が許可されたので、権限が必要なAPIを使用する処理へ進む
                findWebCams ();
                findMicrophones ();
            } else {
                // 権限が許可されなかったので、ユーザーに対して権限の使用用途の説明を表示してから再度のリクエストを行う。
                // もしも拒否時に「今後表示しない」がチェックされた場合は、次回からリクエスト自体が表示されなくなる、
                // そのためユーザーには自分でOSのアプリ設定画面で権限許可を行うようにアナウンスする必要がある。
                // (Permissionクラスにはそれらの違いを調べる方法は用意されていない)
            }

            #endif

            yield break;
        }

#if (UNITY_IOS && UNITY_2018_1_OR_NEWER) || (UNITY_ANDROID && UNITY_2018_3_OR_NEWER)
        bool isRequesting;

        // OSの権限要求ダイアログを閉じたあとに、アプリフォーカスが復帰するのを待ってから権限の有無を確認する必要がある
        IEnumerator OnApplicationFocus(bool hasFocus)
        {
            // iOSプラットフォームでは1フレーム待つ処理がないと意図通りに動かない。
            yield return null;

            if (isRequesting && hasFocus)
            {
                isRequesting = false;
            }
        }

        #if UNITY_IOS
        IEnumerator RequestUserAuthorization(UserAuthorization mode)
        {
            isRequesting = true;
            yield return Application.RequestUserAuthorization(mode);
            // iOSではすでに権限拒否状態だとダイアログが表示されず、フォーカスイベントが発生しない。
            // その状態を判別する方法が見つからないので、タイムアウト処理をする。

            // アプリフォーカスが戻るまで待機する
            float timeElapsed = 0;
            while (isRequesting)
            {
                if (timeElapsed > 0.5f){
                    isRequesting = false;
                    yield break;
                }
                timeElapsed += Time.deltaTime;

                yield return null;
            }
            yield break;
        }
        #elif UNITY_ANDROID
        IEnumerator RequestUserPermission(string permission)
        {
            isRequesting = true;
            Permission.RequestUserPermission(permission);
            // Androidでは「今後表示しない」をチェックされた状態だとダイアログは表示されないが、フォーカスイベントは通常通り発生する模様。
            // したがってタイムアウト処理は本来必要ないが、万が一の保険のために一応やっとく。

            // アプリフォーカスが戻るまで待機する
            float timeElapsed = 0;
            while (isRequesting)
            {
                if (timeElapsed > 0.5f){
                    isRequesting = false;
                    yield break;
                }
                timeElapsed += Time.deltaTime;

                yield return null;
            }
            yield break;
        }
        #endif
#endif

        void findWebCams ()
        {
            foreach (var device in WebCamTexture.devices) {
                Debug.Log ("Name: " + device.name);
            }
        }

        void findMicrophones ()
        {
            foreach (var device in Microphone.devices) {
                Debug.Log ("Name: " + device);
            }
        }
    }
}

 

読みにくくてすみません、コードの意図は必要以上に詳細なコメントを読んで理解してください。
iOS/Android実機でコードを試した結果、とりあえず期待通りに動作していることを確認しました。

OnApplicationFocus()を使用してアプリフォーカスの復帰を待機する処理は、
RequestUserAuthorization as a coroutine - bugged?
のスレッドのやりとりをヒントにしています。
このためコードがかなり複雑化してしまいました。

とにかく、権限が必要なAPIを利用する前に、あらかじめこのような処理を挟んでおくこで、アプリがクラッシュするなどの事態を避けることが出来るようになりました。

APIが追加される前の古いUnityバージョンではどうする?

Androidでは以下の記事の方法で可能です。ネイティブプラグインが必要無いので気軽に導入できる方法です。
UnityでAndroidのランタイムパーミッションに対応する
iOSでもAndroidでもAssetプラグインを使えば同様の事が実現可能です。たぶん無料のものも存在するはず。

最新のUnityのAPIでも権限の処理には不十分な点も

UnityのAPIは必要最小限の簡易的なものしか用意されていません。
ネイティブアプリと同等の権限の処理をしたい場合は、やはりネイティブプラグインの利用を検討する必要があるでしょう。

参考リンク

UnityにおけるAndroidアプリのパーミッション付与について

 

 

[출처] qiita.com/utibenkei/items/65b56c13f43ce5809561

 

UnityでiOSとAndrodのランタイムパーミッションの確認と要求を行う方法 - Qiita

Unityでアプリのカメラ権限の確認&要求ってどうやるの? これまでのUnityでのアプリ開発では、iOS/Android端末の機能の権限のチェックやリクエストをするために、ネイティブプラグインを利用

qiita.com

 

반응형
Posted by blueasa
, |

Unity2018에서 Unity2019로 올려보면서 나오는 에러 정리

 

그렇게 큰 이슈는 없는 듯 하고, GUIText와 GUITexture가 obsolete 되면서 나온 이슈 뿐인 것 같다.

 

[Error:1] error CS0619: 'GUIText' is obsolete: 'GUIText has been removed. Use UI.Text instead.'

  -> GUIText -> UnityEngine.UI.Text 로 변경

 

[Error:2-1] error CS0619: 'GUITexture' is obsolete: 'GUITexture has been removed. Use UI.Image instead.'

  -> GUITexture -> UnityEngine.UI.Image 로 변경

 

[Error:2-2] error CS1061: 'Image' does not contain a definition for 'texture' and no accessible extension method 'texture' accepting a first argument of type 'Image' could be found (are you missing a using directive or an assembly reference?)

  -> Texture2D를 Sprite로 변환해서 처리

 

public void CameraFadeAdd(Texture2D texture)
{
  ....
  //Create Sprite from the Texture2D
  Sprite tempSprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);
  cameraFade.GetComponent().sprite = tempSprite;
  ....
}

[Error:2-2 참조] stackoverflow.com/questions/53491613/guitexture-is-deprecated-so-what-should-i-use-instead-of-it

 

[Error:3] 

[해당 씬에 접근 했을 때 Error]

- Component GUI Layer in Main Camera for Scene Assets/Scenes/InGame.unity is no longer available. It will be removed after you edit this GameObject and save the Scene. UnityEditor.SceneManagement.EditorSceneManager:OpenScene(String)

[빌드 할 때 Error]

- Component GUI Layer in Main Camera for Scene Assets/Scenes/InGame.unity is no longer available. It will be removed after you edit this GameObject and save the Scene. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

- Component at index 2 could not be loaded when loading game object 'Main Camera'. Removing it!
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

  -> 해당 Scene으로 가서 Hierarchy에서 임의 수정 후 Save 하면 해결 됨.

 

[Error:3 참조]

Baroni 2020년 8월 12일 오전 6:43

All of them can be ignored. Just open the scenes once and save them.

[참조링크] www.rebound-games.com/forum/topic/2485/networkmanager-networkscenename-cannot-be-used-in-this-context-because-the-set-accessor-is-inaccessible/5

반응형
Posted by blueasa
, |

[추가] Android / iOS 방식이 달라서 플랫폼에 따라 Two Letter ISO 받는 방식을 다르게 적용

 

    /// <summary>
    /// Two Letter ISO Language
    /// [참조] https://lonewolfonline.net/list-net-culture-country-codes/
    /// [참조] https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
    /// </summary>
    /// <returns></returns>
    public static string GetTwoLetterISOLanguage()
    {
        string strCurrentCultureName = "en";
#if UNITY_EDITOR
        strCurrentCultureName = "en";
#elif UNITY_ANDROID
        strCurrentCultureName = GetTwoLetterISOLanguage_Android();
#elif UNITY_IOS || UNITY_IPHONE
        strCurrentCultureName = GetTwoLetterISOLanguage_iOS();
#endif
        return strCurrentCultureName;
    }

    public static string GetTwoLetterISOLanguage_iOS()
    {
        string strTwoLetterISOLanguageName = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
        Debug.LogFormat("[GetCurrentCultureName_iOS] {0}", strTwoLetterISOLanguageName);
        return strTwoLetterISOLanguageName;
    }

    // returns "en" / "de" / "hi" / "th" / "ar" / ...
    public static string GetTwoLetterISOLanguage_Android()
    {
#if !UNITY_EDITOR && UNITY_ANDROID
        try
        {
            var locale = new AndroidJavaClass("java.util.Locale");
            var localeInst = locale.CallStatic<AndroidJavaObject>("getDefault");
            var name = localeInst.Call<string>("getLanguage");
            Debug.LogFormat("[getLanguage] {0}", name);
            return name;
        }
        catch (System.Exception e)
        {
            return "Error";
        }
#else
        return "Not supported";
#endif
    }

    // returns "eng" / "deu" / "hin" / ...
    public static string GetThreeLetterISOLanguage_Android()
    {
#if !UNITY_EDITOR && UNITY_ANDROID
        try
        {
            var locale = new AndroidJavaClass("java.util.Locale");
            var localeInst = locale.CallStatic<AndroidJavaObject>("getDefault");
            var name = localeInst.Call<string>("getISO3Language");
            Debug.LogFormat("[getISO3Language] {0}", name);
            return name;
        }
        catch (System.Exception e)
        {
            return "Error";
        }
#else
        return "Not supported";
#endif
    }

[출처]

answers.unity.com/questions/729801/using-applicationsystemlanguage-returns-unknown.html?_ga=2.105896064.227436567.1600081424-730033693.1580204381

 

Using Application.systemLanguage returns Unknown - Unity Answers

 

answers.unity.com

 

 

[참조]

You should also be able to use .NET to get the current culture instead:

using System;
using System.Globalization;
using System.Threading;

CultureInfo myCulture = Thread.CurrentThread.CurrentCulture;


// You can then use all these member variables
myCulture.DisplayName
myCulture.EnglishName
myCulture.Name (e.g. es-ES / en-GB)
myCulture.Parent (e.g. es / en)
myCulture.ThreeLetterISOLanguageName (e.g. spa/eng/hin)
myCulture.TwoLetterISOLanguageName (e.g. es/en/hi)

 

Here's a selection of the Indian 3 and 2 letter ISO codes (see attached jpg)

 

[출처] forum.unity.com/threads/automatically-set-hindi-language.624973/

 

Automatically set Hindi language

As you all know it's possible to use SystemLanguage to detect the default language of the device running the game. When my game opens, i use it to...

forum.unity.com

 

반응형
Posted by blueasa
, |
using System;
using Mono.Data.Sqlite;

public class Example
{

    static void Main() 
    {
        string cs = "URI=file:test.db";        
        
        using (SqliteConnection con = new SqliteConnection(cs)) 
        {
            con.Open();

            using(SqliteTransaction tr = con.BeginTransaction())
            {
                using (SqliteCommand cmd = con.CreateCommand())
                {

                    cmd.Transaction = tr;
                    cmd.CommandText = "DROP TABLE IF EXISTS Friends";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = @"CREATE TABLE Friends(Id INTEGER PRIMARY KEY, 
                                        Name TEXT)";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Tom')";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Rebecca')";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Jim')";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Robert')";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Julian')";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Jane')";
                    cmd.ExecuteNonQuery();
                }

                tr.Commit();
            }

            con.Close();
        }
    }
}

 


출처: https://unsigned.tistory.com/entry/Sqlite-Insert-속도-문제시 [공부하자 공부공부]

 

Sqlite Insert 속도 문제시

using System; using Mono.Data.Sqlite; public class Example { static void Main() { string cs = "URI=file:test.db"; using (SqliteConnection con = new SqliteConnection(cs)) { con.Open(); using(SqliteTr..

unsigned.tistory.com

 

 

반응형
Posted by blueasa
, |

[추가]

- 상대경로 기준 : 프로젝트 폴더

 

프로젝트 하위 폴더

프로젝트 하위에 위와 같이 Keystore 폴더 아래 debug.keystore 파일이 있을 때 상대경로는 아래와 같다.

[상대경로] ./Keysotre/debug.keystore

 

----------------------------------------------------------------------------------------------------------

유니티의 안드로이드 빌드 환경을 설정에서 키스토어 파일을 등록할 때, 일반적으로 Browe Keystore 버튼으로 파일을 등록하게 되면 위 사진과 같이 절대경로가 설정된다.

 

자동 빌드 환경이나, 서로 다른 빌드 머신에서 빌드하고자 할 때 굉장히 짜증나는 부분이며 제대로된 해결 방법은 없고 편법을 사용해야 하는 것을 보인다.

 

유니티 상단 메뉴 -> Edit -> Project Settings -> Editor -> Asset Serialization

값을 Force Text 로 변경한다.

이 작업은 다른 설정 또는 .unity 파일도 모두 변경합니다.

 

프로젝트 경로 -> ProjectSettings 폴더 -> ProjectSettings.asset 을 열면 텍스트로 변환되어 있다. 이중 AndroidKeystoreName 을 검색하여 절대 경로를 상대 경로로 변경한다.

 

유니티를 다시 실행시켜 결과를 확인한다.

 

 

빌드 머신에서 실행해 결과를 확인한다.



출처: https://pjc0247.tistory.com/44 [pjc0247]

 

[Unity] Android keystore 경로 상대경로로 지정하기

유니티의 안드로이드 빌드 환경을 설정에서 키스토어 파일을 등록할 때, 일반적으로 Browe Keystore 버튼으로 파일을 등록하게 되면 위 사진과 같이 절대경로가 설정된다. 자동 빌드 환경이나, 서로

pjc0247.tistory.com

 

반응형
Posted by blueasa
, |

 

[링크] https://mentum.tistory.com/376

 

유니티 프로모션용 영상/동영상 촬영

유니티에서 프로모션 영상을 제작할 때 1. 에디터에서 OBS 등으로 직접 영상 촬영 2. 디바이스에 넣은 상태로 영상촬영 정도로 프로모션 영상 소스를 제작하곤 했는데, iOS용 프로모션 동영상을 만들 때 문제가 되..

mentum.tistory.com

 

반응형
Posted by blueasa
, |

Unity Editor-Edit-Preferences-General에 보면 Script Changes While Playing 옵션이 있다.

 

기본이 위 스크린샷 처럼 'Recompile And Continue Playing'이라서, 플레이 중에 소스 수정하면 리컴파일 되고 에러가 열심히 난다

 

플레이 중엔 리컴파일 안되도록 막기 위해서 2번째인 'Recompile After Finished Playing'로 바꿨다.

 

 

[출처] 게임코디-핑크님

반응형
Posted by blueasa
, |