using System.Collections; using System.Collections.Generic; #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.UIElements; namespace BITKit { [System.Serializable] public record UnityReference : IReference { [SerializeField] internal int index; private AssetableReference asset; public string Get() { asset ??= Addressables.LoadAssetAsync(nameof(AssetableReference)).WaitForCompletion(); return asset.Get(index); } internal void Set(int _index) => index = _index; } public class AssetableReference:ScriptableObject { [SerializeField] private List values; internal string Get(int index) => values[index]; } #if UNITY_EDITOR [CustomPropertyDrawer(typeof(UnityReference))] public class UnityReferenceInspector :PropertyDrawer { public override VisualElement CreatePropertyGUI(SerializedProperty property) { var index = property.FindPropertyRelative(nameof(UnityReference.index)).intValue; return new Label(index.ToString()); } public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var index = property.FindPropertyRelative(nameof(UnityReference.index)).intValue; //var unityReference = property.serializedObject.targetObject.GetType().GetField(property.name).GetValue(property.serializedObject) as UnityReference; EditorGUI.DrawRect(position,Color.gray); //EditorGUI.LabelField(position,new GUIContent(unityReference.index.T } } #endif }