1
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine.UIElements;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
@@ -51,48 +52,32 @@ namespace BITKit.UX
|
||||
}
|
||||
public class UXData : MonoBehaviour
|
||||
{
|
||||
[SerializeReference, SubclassSelector] public References key;
|
||||
[SerializeReference, SubclassSelector] public DataComponents dataParser;
|
||||
bool initialized;
|
||||
void OnEnable()
|
||||
[SerializeReference, SubclassSelector] private IReference key;
|
||||
[SerializeReference, SubclassSelector] private IDataComponent dataParser;
|
||||
private async void Start()
|
||||
{
|
||||
dataParser.SetKey(key);
|
||||
if (initialized)
|
||||
{
|
||||
dataParser.OnStart();
|
||||
}
|
||||
await UniTask.NextFrame();
|
||||
if (destroyCancellationToken.IsCancellationRequested) return;
|
||||
dataParser.SetKey(key.Value);
|
||||
dataParser.OnStart();
|
||||
destroyCancellationToken.Register(dataParser.OnStop);
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
if (initialized is false)
|
||||
{
|
||||
dataParser.OnStart();
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
dataParser.OnStop();
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.CustomEditor(typeof(UXData))]
|
||||
public class UXDataInspector : BITInspector<UXData>
|
||||
{
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
CreateSubTitle(Constant.Header.Settings);
|
||||
var key = root.Create<PropertyField>();
|
||||
CreateSubTitle(Constant.Header.Reference);
|
||||
var dataParser = root.Create<PropertyField>();
|
||||
|
||||
key.bindingPath = nameof(UXData.key);
|
||||
dataParser.bindingPath = nameof(UXData.dataParser);
|
||||
return root;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// #if UNITY_EDITOR
|
||||
// [UnityEditor.CustomEditor(typeof(UXData))]
|
||||
// public class UXDataInspector : BITInspector<UXData>
|
||||
// {
|
||||
// public override VisualElement CreateInspectorGUI()
|
||||
// {
|
||||
// CreateSubTitle(Constant.Header.Settings);
|
||||
// var key = root.Create<PropertyField>();
|
||||
// CreateSubTitle(Constant.Header.Reference);
|
||||
// var dataParser = root.Create<PropertyField>();
|
||||
//
|
||||
// key.bindingPath = nameof(UXData.key);
|
||||
// dataParser.bindingPath = nameof(UXData.dataParser);
|
||||
// return root;
|
||||
// }
|
||||
// }
|
||||
// #endif
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user