This commit is contained in:
CortexCore
2023-11-15 23:55:06 +08:00
parent 5446067f91
commit 70247f0242
82 changed files with 3271 additions and 579 deletions

View File

@@ -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
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b1019fae5b305474fa9f3df5cea55a59
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8d8750340a808e9468c8fcc9ca7e29a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: