はじめに
「AssetPathAttribute」を Unity プロジェクトに導入することで
Inspector でアセットのパス文字列を
アセットのドラッグ&ドロップで設定できるようになります
使い方
using UnityEngine; public sealed class Example : MonoBehaviour { [AssetPath.Attribute( typeof( Object ) )] public string objectValue; [AssetPath.Attribute( typeof( GameObject ) )] public string gameObjectValue; [AssetPath.Attribute( typeof( AudioClip ) )] public string audioClipValue; [AssetPath.Attribute( typeof( ScriptableObject ) )] public string scriptableObject; [AssetPath.Attribute( typeof( Texture2D ) )] public string texutre2D; [AssetPath.Attribute( typeof( Animator ) )] public string animator; [AssetPath.Attribute( typeof( AudioSource ) )] public string audioSource; [AssetPath.Attribute( typeof( Transform ) )] public string transform; }
上記のように string 型の変数に AssetPath.Attribute 属性を適用すると
Inspector でアセットをドラッグ&ドロップして
パス文字列を設定できるようになります