コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Compressed texture XXXX is used as icon. This might compromise visual quality of the final image. Uncompressed format might be considered as better import option.

概要 Compressed texture XXXX is used as icon. This might compromise visual quality of the final image. Uncompressed format might be considered as better import option. Android ビルド時に上記の警告ログが出力される現象に遭遇した アイコンに使…

【Unity】There can be only one active Event System.

概要 シーンにアクティブな EventSystem が 2 つ以上存在する場合に There can be only one active Event System. 上記の警告ログが出力される現象に遭遇した EventSystem が 1 つになるようにしたら出力されなくなった

【Unity】シーン遷移後に長押し判定が残ってしまう場合の対処方法

はじめに ボタンを長押ししたらシーン遷移できる機能を実装したところ、 シーン遷移後にも長押し判定が残ってしまい、 指を離した時に遷移後のシーンのボタンが反応してしまう現象に遭遇した Unity エディタでは再現せず、iOS / Android 実機でのみ発生して…

【Unity】Application.backgroundLoadingPriority が反映されない場合

概要 using UnityEngine; public class Example : MonoBehaviour { private void Awake() { Application.backgroundLoadingPriority = ThreadPriority.High; } [RuntimeInitializeOnLoadMethod( RuntimeInitializeLoadType.BeforeSceneLoad )] private stati…

【Unity】Error building Player: Exception: OBSOLETE - Providing Android resources in Assets/Plugins/Android/res was removed, please move your resources to an AAR or an Android Library. See "AAR plug-ins and Android Libraries" section of the Manual for more

はじめに Error building Player: Exception: OBSOLETE - Providing Android resources in Assets/Plugins/Android/res was removed, please move your resources to an AAR or an Android Library. See "AAR plug-ins and Android Libraries" section of th…

【Unity】BetterStreamingAssets: file assets/XXXX is where Streaming Assets are put, but is compressed.

概要 BetterStreamingAssets: file assets/XXXX is where Streaming Assets are put, but is compressed. If this is a App Bundle build, see README.md for a possible workaround. If this file is not a Streaming Asset (has been on purpose by hand o…

【Unity】Parent directory must exist before creating asset at Assets/XXXX.

概要 using UnityEditor; using UnityEngine; public class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var material = new Material( Shader.Find( "Specular" ) ); AssetDatabase.CreateAsset( material, "Assets/Hoge/Material.…

【Unity】UnityException: XXXX is not allowed to be called from a MonoBehaviour constructor

概要 UnityException: XXXX is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'YYYY'. 上記のようなエラーが発生した場合は using UnityEngi…

【Unity】TextMesh Pro でルビを振る時に表示位置がズレる場合の対処方法

はじめに <nobr>ピカチュウ<space=-3.75em><voffset=1em><size=50%>ぴかちゅう</size></voffset><space=1.25em> 上記のようなタグを使用して TextMesh Pro でルビを振る時に Alignment が左揃えならキレイに表示されるが 中央揃えや 右揃えだと表示位置が右にズレる現象に遭遇した (一行目がルビ無しの場合の正しい位置) ルビを振るテキ</space=1.25em>…

【Unity】TextMesh Pro でルビを振る時に文字間隔を変更していると表示位置がズレる

概要 <nobr>ピカチュウ<space=-3.75em><voffset=1em><size=50%>ぴかちゅう</size></voffset><space=1.25em> 上記のようなタグを使用して TextMesh Pro でルビを振る場合、 文字間隔(Spacing Options (em) の Character)が 0 だと正しい位置で表示されるが たとえば文字間隔を -8 にしているとこのようにルビの表示位置がズレてしまう <nobr>ピ</nobr></space=1.25em>…

【Unity】ScriptTemplates フォルダは Assets 直下じゃないと認識されない

概要 ScriptTemplates フォルダは Assets 直下に作らないと スクリプトテンプレートが認識されなかった

【Unity】 error: Build input file cannot be found: '【XXXX】/Libraries/com.unity.services.core/Runtime/Device/UserIdProviders/NSUserDefaults.mm' (in target 'UnityFramework' from project 'Unity-iPhone')

概要 error: Build input file cannot be found: '【XXXX】/Libraries/com.unity.services.core/Runtime/Device/UserIdProviders/NSUserDefaults.mm' (in target 'UnityFramework' from project 'Unity-iPhone') Xcode ビルド時に上記のエラーが発生してビル…

【Unity】Diagnostic switches are active and may impact performance or degrade your user experience. Switches can be configured through the Diagnostics section in the Preferences window. ProfileOpenCLJobs: False

概要 Diagnostic switches are active and may impact performance or degrade your user experience. Switches can be configured through the Diagnostics section in the Preferences window. ProfileOpenCLJobs: False Preferences の「Diagnostics」を…

【Rider】Mac でグローバル設定のファイル(GlobalSettingsStorage.DotSettings)がマニュアルに記載されている場所とは別の場所に保存されていた

概要 ~/Library/Preferences/RiderXXX/config/resharper-host/GlobalSettingsStorage.DotSettings マニュアルには上記の場所に保存されていると記載されていたが ~/Library/Application Support/JetBrains/Rider2021.3/resharper-host/GlobalSettingsStorage…

【Unity】iOS の Launch Screen に設定した Image が黒く表示される場合

概要 画像の Texture Type を「Editor GUI and Legacy GUI」から 「Sprite (2D and UI)」に変更したら直った

【Unity】iOS の Launch Screen の設定内容が Xcode に反映されない場合

概要 Build Settings で「Symlink Sources」を有効にしているか スクリプトからビルドする時に BuildOptions.SymlinkSources を使用していると Project Settings で設定した iOS の Launch Screen の内容が Xcode に反映されない

【Unity】DOTween で IndexOutOfRangeException: Index was outside the bounds of the array.

概要 using Cysharp.Threading.Tasks; using DG.Tweening; using UnityEngine; public class Example : MonoBehaviour { private Tween m_tween; private async UniTaskVoid Update() { if ( Input.GetMouseButtonDown( 0 ) ) { Debug.Log( "開始" ); m_twee…

【Unity】BuildOptions.DetailedBuildReport を使用するとビルド時に Unity エディタが強制終了するようになった

概要 BuildOptions.DetailedBuildReport を使用すると ビルド時に Unity エディタが強制終了するようになった Editor.log を見ると以下のログが出力されていた Calling OnPostBuildPlayerScriptDLLs callbacks. For faster build speeds, consider not using…

【Unity】error: No profiles for 'XXXX' were found:

概要 error: No profiles for 'XXXX' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'XXXX'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvi…

【Unity】Bundletool.BuildBundle だと extraScriptingDefines が反映されない?

概要 AppBundleBuilder.BuildAndroidPlayer を見てみたら 引数に渡された BuildPlayerOptions の extraScriptingDefines を使用していなかった PlayerSettings.SetScriptingDefineSymbolsForGroup なら正常に反映された ただし、SetScriptingDefineSymbolsFo…

【Unity】Preferences の「Auto-save scenes before building」が保存されない問題がある

概要 Preferences の「Auto-save scenes before building」を有効にしてから Preferences を閉じて再度 Preferences を開いてみると 「Auto-save scenes before building」が無効になってしまう

【Unity】Play Asset Delivery を導入して Android ビルドしたら DllNotFoundException が発生

概要 DllNotFoundException: /data/app/~~EpCtMMU6o4jMa8tCi-kNiQ==/XXXX-BkCHnxel99lOtmD1A37Utg==/split_config.armeabi_v7a.apk!/lib/armeabi-v7a/libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null) at (wrapper managed-to-native) Interop+Sys.LChflags</unknown></unknown>…

【Unity】Play Asset Delivery 1.8.1 のパッケージを導入して Android ビルドしたらアプリ起動時に強制終了するようになった

概要 Throwing new exception 'No interface method getPackStates(Ljava/util/List;)Lcom/google/android/play/core/tasks/Task; in class Lcom/google/android/play/core/assetpacks/AssetPackManager; or its super classes (declaration of 'com.google.…

【Unity】com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: Installation of the app failed.

概要 Play Asset Delivery 用の Unity プラグインを追加して Bundletool.BuildBundle で Android ビルドを実行したら Installation failed with the following output: Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 The APKs have been extracted in…

【Unity】DeploymentOperationFailedException: Installation failed. See the Console for details.

概要 Play Asset Delivery 用の Unity プラグインを追加して Bundletool.BuildBundle で Android ビルドを実行したら DeploymentOperationFailedException: Installation failed. See the Console for details. UnityEditor.Android.AndroidDeploymentTarget…

【Unity】BuildPipeline.BuildPlayer で iOS ビルドする時に EditorUserBuildSettings.symlinkSources が反映されない場合

概要 EditorUserBuildSettings.symlinkSources = true; var buildReport = BuildPipeline.BuildPlayer( buildPlayerOptions ); 上記のようなコードで iOS ビルドした際に Symlink Sources が有効にならない現象に遭遇した buildPlayerOptions.options |= Bui…

【Unity】Type 'XXXX' has an extra field 'YYYY' of type 'ZZZZ' in the player and thus can't be serialized

概要 Type 'XXXX' has an extra field 'YYYY' of type 'ZZZZ' in the player and thus can't be serialized アセットバンドルビルド時に上記のエラーが発生する現象に遭遇した Library フォルダ内の「BuildPlayerData」を削除してからビルドしたら エラーが…

【Unity】UnityWebRequest.Get と JsonUtility.FromJson で「ArgumentException: JSON parse error: Invalid value.」

概要 using var unityWebRequest = UnityWebRequest.Get( path ); await unityWebRequest.SendWebRequest(); var json = unityWebRequest.downloadHandler.text; var xxxx = JsonUtility.FromJson<XXXX>( json ); UnityWebRequest.Get で読み込んだ JSON を JsonUt</xxxx>…

【Unity】In-App Review API の内部テストでレビューダイアログが 2 回目以降表示されない場合

はじめに Unity で作成している Android アプリに In-App Review API を導入して ビルドした .aab を Google Play Console の内部テストで公開して テスターアカウントでアプリをインストールして動作確認したところ 1 回目は正常にレビューダイアログが表示…

【Unity】java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

概要 Running Gradle... XXXX\Temp\PlayServicesResolverGradle\gradlew.bat --no-daemon -b "XXXX\Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle" "-PANDROID_HOME=C:\Program Files\Unity\Hub\Editor\2022.1.1…