コガネブログ

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

【Unity】Addressables の Asset Group の Inspector で Advanced Options を常に開いた状態にしたい場合

検証環境 Addressables 1.16.19 概要 Addressable Asset Group の Inspector で Advanced Options は デフォルトが閉じた状態なので、各グループの Advanced Options を見たい場合に 毎回 Advanced Options の ▶ をクリックして開く必要がある BundleAssetGr…

【Unity】Addressables で Basic 認証が設定されたサーバからリモートカタログをダウンロードする方法

検証環境 Addressables 1.16.19 概要 Addressables はデフォルトでは Basic 認証が設定されたサーバから リモートカタログをダウンロードすることができない TextDataProvider.Start 関数で UnityWebRequest を使用して リモートカタログのダウンロードが実…

【Unity】Addressables でストレージの空き容量が不足している時にリモートカタログをダウンロードしても正常に動作するように

検証環境 Addressables 1.16.19 概要 Addressables ではサーバからダウンロードしたリモートカタログを 端末のキャッシュに保存する際に、ストレージの空き容量を確認していない そのため、空き容量が不足していると File.WriteAllText で例外が発生して Con…

【Unity】Addressables の LoadScene でアセットバンドルの読み込みに失敗した時に進行不能にならないようにする方法

検証環境 Addressables 1.16.19 概要 Addressables の LoadScene でシーン遷移する時に 通信環境が悪いなどの理由でアセットバンドルの読み込みに失敗した場合、 SceneProvider で AsyncOperationBase.Complete が呼ばれなくなり それ以降 Addressables の A…

【Unity】Addressables でリモートカタログをキャッシュに保存する時にメインスレッドが止まらないようにする方法

検証環境 Addressables 1.16.19 概要 Addressables で管理しているグループが多いと、 リモートカタログをキャッシュに保存する処理に時間がかかるようになり、 メインスレッドが止まってしまう 重たい処理は ContentCatalogProvider.OnCatalogLoaded 関数で…

【Unity】Addressables のビルドを Jenkins から実行する場合にビルドに失敗しても成功扱いにならないようにする方法

検証環境 Addressables 1.16.19 概要 Jenkins から Addressables のビルドを実行する場合、 アセットバンドルのビルドに失敗しても、 Jenkins 上ではビルドに成功したことになってしまった アセットバンドルをビルドする AddressableAssetSettings.BuildPlay…

【Unity】Addressables でリモートカタログの更新が存在するか確認する時にメインスレッドが止まらないようにする方法

検証環境 Addressables 1.16.19 概要 Addressables で管理しているグループが多いと、 Addressables.CheckForCatalogUpdates の処理に時間がかかるようになり、 メインスレッドが止まってしまう 重たい処理は CheckCatalogsOperation.Execute 関数なので こ…

【Unity】Addressables でカタログの JSON を読み込む時にメインスレッドが止まらないようにする方法

検証環境 Addressables 1.16.19 概要 Addressables で管理しているグループが多いと、 カタログの JSON のサイズが大きくなり、 カタログの読み込みに時間がかかるようになり、メインスレッドが止まってしまう カタログは JSONAssetProvider クラスで JsonUt…

【Unity】Addressable Asset System で無効なファイルや Unity がサポートしていないファイルを無視する方法

概要 1.17.0 以降の Addressable Asset System なら AddressableAssetSettings の「Ignore Invalid/Unsupported Files in Build」をオンにすると 無効なファイルや Unity がサポートしていないファイルを無視できる

【Unity】Addressable Asset System でカタログのサイズを減らす方法

概要 1.16.10 以降の Addressable Asset System なら AddressableAssetSettings の「Optimize Catalog Size」をオンにすると カタログのサイズを減らせる

【Unity】Addressable Asset System でアセットバンドルの読み込み速度を改善する方法

概要 1.13.1 以降の Addressable Asset System なら AddressableAssetSettings の「Contiguous Bundles」をオンにすると アセットバンドルの読み込み速度を改善できるらしい Added AddressableAssetSettings.ContiguousBundles option, which when enabled w…

【Unity】ArgumentException: Asset 'Assets/__DELETED_GUID_Trash/XXXX' is not a valid Asset or Scene.

概要 ArgumentException: Asset 'Assets/__DELETED_GUID_Trash/XXXX' is not a valid Asset or Scene. Addressable でアセットバンドルをビルドする時に 上記のエラーが発生してビルドに失敗する現象に遭遇した Unity を再起動してからアセットバンドルをビ…

【Unity】Broken text PPtr in file(XXXX.unity). Local file identifier (YYYY) doesn't exist!

概要 Broken text PPtr in file(XXXX.unity). Local file identifier (YYYY) doesn't exist! Addressable でアセットバンドルをビルドする時に 上記のエラーが発生する現象に遭遇した 該当のシーンファイルのフォーマットが バージョンアップ前の Unity のも…

【Unity】Addressable Asset System の AddressableAssetGroup に登録されているエントリが重複していないか確認するテストコード

概要 using System.Collections.Generic; using System.Linq; using System.Reflection; using NUnit.Framework; using UnityEditor; using UnityEditor.AddressableAssets; using UnityEditor.AddressableAssets.Settings; public sealed class Addressable…

【Unity】Addressable Asset System の AddressableAssetSettings に登録されているグループが重複していないか確認するテストコード

概要 using System.Linq; using NUnit.Framework; using UnityEditor.AddressableAssets; using UnityEditor.AddressableAssets.Settings; public sealed class Addressables用テスト { private sealed class DuplicateGroupResult { private readonly strin…

【Unity】Addressable Asset System でビルドできるファイルかどうかを確認する方法

概要 using UnityEditor; using UnityEngine; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var path = AssetDatabase.GetAssetPath( Selection.activeObject ); var mainAssetType = AssetDatabase.GetMainAsse…

【Unity】GitHub に公開している自作の Unity パッケージ300個以上紹介

はじめに 自分が GitHub に公開している Unity パッケージを300個以上まとめました 各パッケージは Unity Package Manager からインストール可能です まだドキュメントを記載できていないパッケージもあるのでご了承ください 多くのパッケージのライセンスは…

【Unity】Addressable Asset System ですべての Missing Reference なグループを削除するエディタ拡張

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

【Unity】エディタ拡張で Addressable Asset System の Profile の情報を取得するサンプル

ソースコード

【Unity】Addressable Asset System のテンプレートとグループの設定が等しいか確認するクラス

ソースコード 使用例 using UnityEditor; using UnityEditor.AddressableAssets; using UnityEditor.AddressableAssets.Settings; using UnityEngine; public class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var settings = Addr…

【Unity】IOException: Directory Library/BuildCache\XXXX is not empty

概要 IOException: Directory Library/BuildCache\XXXX is not empty Addressable Asset System を使用しているプロジェクトで BuildCache.PurgeCache( false ); を実行したところ 上記の例外が発生することがあった 一度、手動で Library/BuildCache フォル…

【Unity】Addressable Asset System の2回目以降の InitializeAsync で進行不能になった場合

概要 Addressable Asset System 1.8.4 を使用しているプロジェクトで カタログがキャッシュに存在する状態で InitializeAsync を実行すると 進行不能になる現象に遭遇した 1.8.5 にアップデートしても直らなかった 1.9.2 にアップデートしたら直った

【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…