コガネブログ

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

【Unity】Addressable Asset System のビルドのキャッシュの保存先

概要 【Unity プロジェクト】/Library/BuildCache Addressables Goups ウィンドウの 「Build > Clean Build > All」で削除されるのはこのフォルダ

【Unity】Addressable Asset System でダウンロード対象のアセットバンドルの容量を取得する方法

概要 var handle = Addressables.GetDownloadSizeAsync( address ); handle.Completed += _ => Debug.Log( handle.Result ); Addressables.GetDownloadSizeAsync を使用することで ダウンロード対象のアセットバンドルの容量を取得できる ダウンロード対象の…

【Unity】Addressable Asset System でデフォルト以外のすべての空のグループを削除するエディタ拡張

概要 使用例 using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { AddressableUtils.RemoveAllEmptyGroupWithoutDefault(); } }

【Unity】Addressable Asset System のグループ名を昇順でソートするエディタ拡張

概要 使用例 using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] public static void Hoge() { // グループを名前でソートします AddressableUtils.SortGroups(); // AddressableAssetsWindow の描画を更新します AddressableUti…

【Unity】Addressable Asset System の AddressableAssetsWindow を再描画するエディタ拡張

using System.Reflection; using UnityEditor; using UnityEngine; public static class Example { [MenuItem( "Tools/Hoge" )] public static void Repaint() { const BindingFlags attr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.Non…

【Unity】Addressable Asset System で重複しているアドレスが存在しないか確認するテストコード

概要 使用例 using NUnit.Framework; using System.Linq; using System.Text; public static class Example { [Test] public static void CheckDuplicateAddress() { var list = AddressableUtils .GetDuplicateAddress() .ToArray() ; var isExist = list.A…

【Unity】Addressable Asset System の BundledAssetGroupSchema の Build Path と Load Path を変更するエディタ拡張

概要 使用例 using System.Linq; using UnityEditor; using UnityEditor.AddressableAssets.Settings; using UnityEditor.AddressableAssets.Settings.GroupSchemas; public static class Example { [MenuItem( "Tools/Hoge" )] public static void Hoge() {…

【Unity】Addressable Asset System 1.7.4 Changelog

概要 建物カタログデータの速度が向上しました。 サブオブジェクトの処理に関連するさまざまなマイナーな最適化。 ビルドプロセスのカタログ生成部分にプログレスバーを追加しました。 初期化オブジェクトに非同期初期化APIを提供します。 CacheInitializati…

【Unity】Addressable Asset System を使用しているプロジェクトで従来のアセットバンドル名の仕組みを使用していると表示される警告

概要 Legacy Bundles Detected We have detected the use of legacy bundles in this project. Would you like to auto-convert those into Addressables? This will take each asset bundle you have defined (we have detected X bundles), create an Addr…

【Unity】Addressable Asset System でアドレスが重複している状態でアセットバンドルをビルドした時に出力されたエラー

概要 ArgumentException: An item with the same key has already been added. Key: 【GUID】 エラーログに出力された GUID からアセットを調べてみたところ、 そのアセットのアドレスが二重に登録されている状態だった 二重に登録されているアドレスをすべ…

【Unity】Addressable Asset System の AssetBundleRequestOptions でハッシュ値や CRC、ビルドサイズを取得できる

概要 public sealed class Example : IAssetBundleResource { public void Setup( ProvideHandle handle ) { var options = handle.Location.Data as AssetBundleRequestOptions; // ハッシュ値 Debug.Log( options.Hash ); // CRC 値 Debug.Log( options.Cr…

【Unity】Addressable Asset System の BundledAssetGroupSchema.AssetBundleProviderType を変更するエディタ拡張

概要 使用例 using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var group = AddressableUtils.GetOrCreateGroup( "【グループ名】" ); var bundledAssetGroupSchema = group.Schemas .OfType<BundledAssetGroupSchema>() .</bundledassetgroupschema>…

【Unity】Addressable Asset System の BundledAssetGroupSchema.BundleNaming を変更するエディタ拡張

概要 使用例 public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var group = AddressableUtils.GetOrCreateGroup( "【グループ名】" ); var bundledAssetGroupSchema = group.Schemas .OfType<BundledAssetGroupSchema>() .FirstOrDefault() ; </bundledassetgroupschema>…

【Unity】Addressable Asset System の設定が変更された時に呼び出されるイベント

概要 using UnityEditor; using UnityEditor.AddressableAssets.Settings; using UnityEngine; [InitializeOnLoad] public static class Example { static Example() { AddressableAssetSettings.OnModificationGlobal += OnModificationGlobal; } private s…

【Unity】Addressable Asset System の AddressableAssetEntry.SetAddress はアドレスが変更された時のみ処理が実行されるようになっている

概要 public void SetAddress(string addr, bool postEvent = true) { if (m_Address != addr) { m_Address = addr; if (string.IsNullOrEmpty(m_Address)) m_Address = AssetPath; SetDirty(AddressableAssetSettings.ModificationEvent.EntryModified, thi…

【Unity】Addressable Asset System の Play Mode Script を変更するエディタ拡張

概要 使用例 using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { // デフォルトなら // 0: Use Asset Database (faster) // 1: Simulate Groups (advanced) // 2: Use Existing Build (requires bu…

【Unity】Addressable Asset System でデフォルト以外のすべてのグループを削除するエディタ拡張

概要 使用例 using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { AddressableUtils.RemoveAllGroupWithoutDefault(); } }

【Unity】Addressable Asset System でアセットやフォルダにラベルを割り当てる・解除するエディタ拡張

概要 使用例 using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { // アセットにラベルを割り当てます AddressableUtils.SetLabelToAssetOrFolder ( path:"Assets/New Material.mat", label: "hoge"…

【Unity】Addressable Asset System でアセットやフォルダにアドレスを割り当ててグループに追加するエディタ拡張

概要 使用例 using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { // アセットにアドレスを割り当ててグループに追加する AddressableUtils.SetAddressToAssetOrFolder ( path:"Assets/New Material…

【Unity】Addressable Asset System のグループを作成するエディタ拡張

概要 使用例 using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var group = AddressableUtils.GetOrCreateGroup( "test" ); } }

【Unity】エディタ拡張で Addressable Asset System のビルド・クリーンを実行する方法

概要 using UnityEditor; using UnityEditor.AddressableAssets.Settings; public static class Test { [MenuItem( "Tools/Build" )] private static void Build() { AddressableAssetSettings.BuildPlayerContent(); } [MenuItem( "Tools/Clean" )] private…

【Unity】Addressable Asset System で詳細なログ出力を有効にする方法

概要 シンボル定義に「ADDRESSABLES_LOG_ALL」を追加する

【Unity】Addressable Asset System の実行時エラーログを無効化する方法

概要 AddressableAssetSettings の「Log Runtime Exceptions」をオフにする

【Unity】Addressable Asset System の ExceptionHandler で例外が出力されたキーと型をログ出力するサンプル

概要 using System; using System.Text.RegularExpressions; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement; using UnityEngine.ResourceManagement.AsyncOperations; internal sealed class Example : Mo…

【Unity】Addressable Asset System で例外を検知する方法

概要 try~catch で例外を検知することはできない ResourceManager.ExceptionHandler で例外を検知することができる Application.LogCallback のようなもの 例外はただの Exception で飛んできてきているようなので、 ResourceManager.ExceptionHandler の引…

【Unity】「Unity AssetBundle 完全に理解した」資料などまとめ

イベントページ 動画 資料 お前はまだ本当のAssetBundleを知らない ごっこランドを支える技術 〜AssetBundle 編〜 誰もAddressableを語らないのなら…俺が語るしかないッ AssetBundleダウンロードサイズ表示対応 サーバ無しでAssetBundleを使う 複数プロジェ…