using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEditor.UIElements; #if UNITY_EDITOR using Cysharp.Threading.Tasks; using UnityEditor; #endif using UnityEngine; using UnityEngine.UIElements; using Object = UnityEngine.Object; namespace BITKit.Events { [Serializable] public class UnityEventData { public Object Target; public string MethodName; } [Serializable] public class UnityEvent { public List Targets = new List(); public void Invoke(params object[] objects) { foreach (var x in Targets) { x.Target.GetType().GetMethod(x.MethodName)?.Invoke(x.Target,objects); } } } #if UNITY_EDITOR [CustomPropertyDrawer(typeof(UnityEvent))] public class UnityEventDataPropertyDrawer:PropertyDrawer { private VisualElement root; private UnityEvent agent; private SerializedProperty _property; public override VisualElement CreatePropertyGUI(SerializedProperty property) { _property = property; agent = property.Get(); root = new VisualElement { style = { paddingLeft = 10, paddingTop = 10, paddingRight = 10, paddingBottom = 10, } }; root.styleSheets.Add(BITEditorUtils.InspectorStyleSheet); Update(); return root; } private void Update() { root.Clear(); var targets = _property.FindPropertyRelative(nameof(UnityEvent.Targets)); _property.serializedObject.Update(); var label = root.Create