1
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
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<AssetableReference>(nameof(AssetableReference)).WaitForCompletion();
|
||||
return asset.Get(index);
|
||||
}
|
||||
internal void Set(int _index) => index = _index;
|
||||
}
|
||||
public class AssetableReference:ScriptableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private List<string> 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
|
||||
}
|
||||
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1019fae5b305474fa9f3df5cea55a59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,12 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class TestAssetableReference : MonoBehaviour
|
||||
{
|
||||
[SerializeReference, SubclassSelector] public IReference reference;
|
||||
public UnityReference UnityReference;
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d8750340a808e9468c8fcc9ca7e29a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user