using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Cryptography; using BITKit.UX; using Newtonsoft.Json; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; using UnityEngine; using UnityEngine.UIElements; namespace BITKit.IData { public class UXDataBindingService : MonoBehaviour { [RuntimeInitializeOnLoadMethod] private static void Reload() { _Binders.Clear(); _Instances.Clear(); } private static readonly Dictionary _Binders = new(); private static readonly CacheList _Instances = new(); public static VisualElement Create(object target) { var visualElement = new VisualElement(); var fields = target.GetType().GetFields(ReflectionHelper.Flags); foreach (var fieldInfo in fields.Where(x=>x.GetCustomAttribute() is not null)) { var handler = UXDataBindingService.Create(target,fieldInfo); var ui = handler.CreateUI(target, fieldInfo); visualElement.Add(ui); } foreach (var methodInfo in target.GetType().GetMethods(ReflectionHelper.Flags)) { if (Attribute.IsDefined(methodInfo, typeof(ExportAttribute)) is false) continue; var exportAttribute = methodInfo.GetCustomAttribute(); var button = visualElement.Create