コガネブログ

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

【Unity】Addressable Asset System で現在の Play Mode Script の名前を取得する方法

概要

#if UNITY_EDITOR

var guidList = UnityEditor.AssetDatabase.FindAssets( "t:AddressableAssetSettings" );
var guid     = guidList.FirstOrDefault();
var path     = UnityEditor.AssetDatabase.GUIDToAssetPath( guid );
var settings = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEditor.AddressableAssets.Settings.AddressableAssetSettings>( path );
var index    = settings.ActivePlayModeDataBuilderIndex;
var builder  = settings.DataBuilders[ index ] as UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptBase;

Debug.Log( $"[Addressable] プレイモードスクリプト:{builder.Name}" );

#endif