diff --git a/src/DebugUtils/Editor/EntlongDrawer.cs b/src/DebugUtils/Editor/EntlongDrawer.cs index 198e42e..891f6af 100644 --- a/src/DebugUtils/Editor/EntlongDrawer.cs +++ b/src/DebugUtils/Editor/EntlongDrawer.cs @@ -1,5 +1,6 @@ #if UNITY_EDITOR using DCFApixels.DragonECS.Unity.Internal; +using System.Reflection; using UnityEditor; using UnityEngine; @@ -90,6 +91,17 @@ namespace DCFApixels.DragonECS.Unity.Editors ent = monitor.Entity; isValide = true; } + else + { + foreach (var beh in go.GetComponents()) + { + if(TryFindEntlong(beh, out ent)) + { + isValide = true; + break; + } + } + } } else { @@ -103,10 +115,20 @@ namespace DCFApixels.DragonECS.Unity.Editors ent = monitor.Entity; isValide = true; } + else + { + if (TryFindEntlong(dragged, out ent)) + { + isValide = true; + } + } } + + if (isValide) { + EditorGUI.ObjectField long entityLong = *(long*)&ent; fulleProperty.longValue = entityLong; } @@ -124,6 +146,34 @@ namespace DCFApixels.DragonECS.Unity.Editors //Event.current.Use(); } + private bool TryFindEntlong(Object uniObj, out entlong ent) + { + var fields = uniObj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + foreach (var field in fields) + { + if(field.FieldType == typeof(entlong)) + { + ent = (entlong)field.GetValue(uniObj); + return true; + } + } + + var iterator = new SerializedObject(uniObj).GetIterator(); + iterator.NextVisible(true); + while (iterator.Next(true)) + { + if (iterator.propertyType == SerializedPropertyType.Integer && + iterator.propertyPath.Contains(nameof(entlong))) + { + var l = iterator.longValue; + ent = *(entlong*)&l; + return true; + } + } + ent = entlong.NULL; + return false; + } + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { const float UNITY_HEIGHT_CONSTANT = 18f; diff --git a/src/Internal/Editor/EcsGUI.cs b/src/Internal/Editor/EcsGUI.cs index 1688846..8e4e9f3 100644 --- a/src/Internal/Editor/EcsGUI.cs +++ b/src/Internal/Editor/EcsGUI.cs @@ -277,7 +277,7 @@ namespace DCFApixels.DragonECS.Unity.Editors public static LabelWidthScope SetLabelWidth(float value) => new LabelWidthScope(value); #endregion - private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + //private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; internal readonly static Color GrayColor = new Color32(100, 100, 100, 255); internal readonly static Color GreenColor = new Color32(75, 255, 0, 255);