コガネブログ

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

【Unity】Addressable Asset System で PercentComplete が正常な値を返してくれない場合

概要 自分の環境だと 1.9.2 以降、PercentComplete が正常な値を返してくれず プログレスバーの表示がおかしくなる現象に遭遇したが PercentComplete 周りの処理のみ 1.8.5 以前のものに戻したら 正常に動作するようになった ChainOperation.cs protected ov…

【Unity】Addressable Asset System で DontDestroyOnLoad したゲームオブジェクトが参照しているアセットやスクリプトが Missing になってしまう現象の対応方法

概要 Note: If you mark a GameObject in an Addressable loaded scene as DontDestroyOnLoad or move it to another loaded Scene and then unload your original Scene, all dependencies for your GameObject are still unloaded. If you find yourself i…

【Unity】MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation

概要 MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[[UnityEngine.AddressableAssets.Initialization.ResourceManagerRuntimeData, Unity.Addressables, Version=0.…

【Unity】Unsaved scenes

概要 Unsaved scenes Addressable Asset System でアセットバンドルをビルドする時に上記のエラーが発生して ビルドできない状況に遭遇した シーンファイルに変更がある状態でビルドを開始すると シーンファイルを保存するかどうか確認するダイアログが表示…

【Unity】SBP ErrorUnsavedChanges

概要 SBP ErrorUnsavedChanges Addressable Asset System でアセットバンドルをビルドする時に上記のエラーが発生して ビルドできない状況に遭遇した シーンファイルに変更がある状態でビルドを開始すると シーンファイルを保存するかどうか確認するダイアロ…

【Unity】Addressable Asset System の DownloadDependenciesAsync で AsyncOperationHandle.PercentComplete が正常な値を返してくれない場合のメモ

概要 自分の環境だと下記のような状況だった バージョン 動作 1.8.3 0.0 ~ 1.0 の値を返してくれる 1.8.4 0.0 ~ 1.0 の値を返してくれる 1.9.2 0.75 ~ 1.0 の値を返してくる 1.10.0 0.75 ~ 1.0 の値を返してくる

【Unity】Addressable Asset System でキャッシュの保存場所や保存期間を変更する方法

概要 Project ビューの「+ > Addressables > Initialization > Cache Initialization Settings」を選択すると アセットバンドルのキャッシュの保存場所や保存期間を設定できるファイルが生成されます 項目 内容 Compress Bundles キャッシュに保存するアセッ…

【Unity】Addressable Asset System を使用している ROM で InitializeAsync 時にエラーが発生した時のメモ

概要 NullReferenceException: Object reference not set to an instance of an object UnityEngine.ResourceManagement.AsyncOperations.InitalizationObjectsOperation.Execute () (at Library/PackageCache/com.unity.addressables@1.10.0/Runtime/Initia…

【Unity】Android 向けにビルドしたアセットバンドルを Unity エディタで読み込んだ時に TextMesh Pro のテキストが表示されない場合

概要 Unity の Project Settings の「Player > Other Settings」を開く 「Auto Graphics API for Windows」のチェックを外す 「Graphics APIs for Windows」を Android プラットフォームと同じ状態にする Unity を再起動する これで Android 向けにビルドし…

【Unity】Addressable Asset System でアセットが削除された時にグループを更新しないようにするエディタ拡張

ソースコード

【Unity】Addressable Asset System でカタログがビルドされている箇所、ランタイムで読み込まれている箇所

リモートカタログがビルドされている箇所 BuildScriptPackedMode.cs CreateRemoteCatalog 関数 WriteFile(remoteJsonBuildPath, jsonText, builderInput.Registry); ローカルカタログがビルドされている箇所 BuildScriptPackedMode.cs CreateCatalogFiles 関…

【Unity】Addressable Asset System で BuildScriptBase を継承したインスタンスを Addressable Groups の Build メニューに追加する方法

概要 BuildScriptBase.CanBuildData 関数をオーバーライドして true を返す Addressable Groups の Build メニューは下記のように生成されている AddressableAssetsSettingsGroupEditor.cs 181行目辺り var menu = new GenericMenu(); for (int i = 0; i < s…

【Unity】Addressable Asset System ですべてのラベルを取得する方法

概要 using UnityEditor; using UnityEditor.AddressableAssets; using UnityEngine; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var settings = AddressableAssetSettingsDefaultObject.Settings; var labels…

【Unity】Addressable Asset System で差分ビルドが必要なエントリを取得する方法

概要 using UnityEditor; using UnityEditor.AddressableAssets; using UnityEditor.AddressableAssets.Build; using UnityEngine; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var settings = AddressableAsse…

【Unity】Addressable Asset System で Unity を再生した時やアセットバンドルをビルドした時に呼び出されるコールバック

概要 using UnityEditor; using UnityEditor.AddressableAssets.Build; using UnityEngine; [InitializeOnLoad] public static class Example { static Example() { BuildScript.buildCompleted += OnBuildCompleted; } private static void OnBuildComplete…

【Unity】Addressable Asset System が依存している Unity Package

概要 com.unity.scriptablebuildpipeline com.unity.test-framework

【Unity】Addressable Asset System における .gitignore の設定

概要 https://github.com/github/gitignore/blob/master/Unity.gitignore 上記の公式の .gitignore に記載されている # Packed Addressables /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* # Temporary auto-generated Android Assets /[Aa]ssets/[Ss…

【おすすめスライド】「【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説」

スライド

【Unity】Unity Package Manager で入手したパッケージの一部を git のバージョン管理に含める方法

概要 /[Ll]ibrary/* !/[Ll]ibrary/PackageCache/ /[Ll]ibrary/PackageCache/* !/[Ll]ibrary/PackageCache/com.unity.addressables@1.7.5/ 例えば Addressable Asset System を git でバージョン管理したい場合、 .gitignore で上記のように記述する

【Unity】Unity Package Manager で入手したパッケージを git のバージョン管理に含める方法

概要 /[Ll]ibrary/* !/[Ll]ibrary/PackageCache/ .gitignore で上記のように記述する

【おすすめスライド】「【リリースが先か】えっ!Addressablesを新規プロジェクトに?【ver1が先か】」

スライド

【Unity】Addressable Asset System の StreamingAssets の settings.json を読み込むスクリプト

概要 StartCoroutine( UniAddressUtils.LoadSettingsJson( c => Debug.Log( c ) ) );

【Unity】Addressable Asset System の StreamingAssets の link.xml を読み込むスクリプト

概要 StartCoroutine( UniAddressUtils.LoadLinkXml( c => Debug.Log( c ) ) );

【Unity】Addressable Asset System の StreamingAssets の catalog.json を読み込むスクリプト

概要 StartCoroutine( UniAddressUtils.LoadCatalogJson( c => Debug.Log( c ) ) );

【Unity】Addressable Asset System の InitializeAsync を複数回呼び出したい場合

概要 Addressables.InitializeAsync でリモートカタログがダウンロードされるが ダウンロードに失敗した場合も内部では初期化済みフラグが立ってしまう AddressablesImpl.hasStartedInitialization がそのフラグ フラグが立ってしまうと、再度 Addressables.…

【Unity】Addressable Asset System の AddressablesImpl.hasStartedInitialization をリフレクションで false にする方法

概要 var addressablesType = typeof( Addressables ); var assembly = addressablesType.Assembly; var addressablesImplType = assembly.GetType( "UnityEngine.AddressableAssets.AddressablesImpl" ); var addressablesImplField = addressablesType.Get…

【Unity】Addressable Asset System の AddressableAssetsData フォルダ以下のアセットはビルドに含まれない

概要 Assets/AddressableAssetsData フォルダ以下のアセットはビルドに含まれない ビルド後に Editor.log の Build Report を見ても含まれていない

【Unity】Addressable Asset System でカタログに記述されているアセットバンドルの一覧をログ出力するエディタ拡張

概要 [MenuItem( "Tools/Hoge" )] private static void Hoge() { var path = @"Library\com.unity.addressables\StreamingAssetsCopy\aa\Windows\catalog.json"; var json = File.ReadAllText( path ); var data = JsonUtility.FromJson<ContentCatalogData>( json ); var intern</contentcatalogdata>…

【Unity】Addressable Asset System で PlatformMappingService.GetAddressablesPlatformInternal をリフレクションで参照する関数

概要 private static AddressablesPlatform GetPlatform( BuildTarget target ) { const string methodName = "GetAddressablesPlatformInternal"; var serviceType = typeof( PlatformMappingService ); var targetType = typeof( BuildTarget ); var metho…

【Unity】Addressable Asset System で Library/com.unity.addressables フォルダをバージョン管理に含める方法

概要 /[Ll]ibrary/* !/[Ll]ibrary/com.unity.addressables/ .gitignore で Library フォルダの無視の指定を上記のように記述する /[Ll]ibrary/ !/[Ll]ibrary/com.unity.addressables/ このように * が付いていないと反映されないので気をつける /[Ll]ibrary/…