From 5dfe28e87df120ebd85ab396478b4a5e6fd405f6 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 13 May 2024 18:21:51 +0800 Subject: [PATCH] add EntityDrawer --- src/Debug/Editor/EntlongDrawer.cs | 26 +++++++++++++++++++ src/Debug/Editor/EntlongDrawer.cs.meta | 11 ++++++++ src/Debug/Editor/SettingsEditor.cs | 6 ++--- .../Editor/EntityTemplateEditor.cs | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 src/Debug/Editor/EntlongDrawer.cs create mode 100644 src/Debug/Editor/EntlongDrawer.cs.meta diff --git a/src/Debug/Editor/EntlongDrawer.cs b/src/Debug/Editor/EntlongDrawer.cs new file mode 100644 index 0000000..efa49e8 --- /dev/null +++ b/src/Debug/Editor/EntlongDrawer.cs @@ -0,0 +1,26 @@ +#if UNITY_EDITOR +using DCFApixels.DragonECS.Unity.Internal; +using UnityEditor; +using UnityEngine; +using static UnityEditor.EditorGUI; + +namespace DCFApixels.DragonECS.Unity.Editors +{ + [CustomPropertyDrawer(typeof(entlong))] + internal class EntlongDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + //base.OnGUI(position, property, label); + using (new DisabledScope(false)) + { + EntitySlotInfo slotInfo = new EntitySlotInfo(property.FindPropertyRelative("_full").longValue); + var (labelRect, barRect) = RectUtility.HorizontalSliceLeft(position, EditorGUIUtility.labelWidth * 0.65f); + + EditorGUI.LabelField(labelRect, label); + EcsGUI.EntityBar(barRect, EcsGUI.EntityStatus.Alive, slotInfo.id, slotInfo.gen, slotInfo.world); + } + } + } +} +#endif \ No newline at end of file diff --git a/src/Debug/Editor/EntlongDrawer.cs.meta b/src/Debug/Editor/EntlongDrawer.cs.meta new file mode 100644 index 0000000..2867c67 --- /dev/null +++ b/src/Debug/Editor/EntlongDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 614e6caafa5d5724fbb3324ea3a60194 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Debug/Editor/SettingsEditor.cs b/src/Debug/Editor/SettingsEditor.cs index fa45d1a..377cfaf 100644 --- a/src/Debug/Editor/SettingsEditor.cs +++ b/src/Debug/Editor/SettingsEditor.cs @@ -51,7 +51,7 @@ namespace DCFApixels.DragonECS.Unity.Editors using (new EcsGUI.ColorScope(Color.white * 0.5f)) GUILayout.BeginVertical(EditorStyles.helpBox); //using (new EcsGUI.ColorScope(Color.white * 1.2f)) - GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f)); + GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f)); Rect rect = GUILayoutUtility.GetLastRect(); rect.xMin += 9f; GUI.Label(rect, "Settings", EditorStyles.whiteLargeLabel); @@ -87,7 +87,7 @@ namespace DCFApixels.DragonECS.Unity.Editors using (new EcsGUI.ColorScope(Color.white * 0.5f)) GUILayout.BeginVertical(EditorStyles.helpBox); //using (new EcsGUI.ColorScope(Color.white * 1.2f)) - GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f)); + GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f)); rect = GUILayoutUtility.GetLastRect(); rect.xMin += 9f; GUI.Label(rect, "Scripting Define Symbols", EditorStyles.whiteLargeLabel); @@ -101,7 +101,7 @@ namespace DCFApixels.DragonECS.Unity.Editors GUILayout.BeginHorizontal(); var symbol = _defineSymbols[i]; symbol.isOn = EditorGUILayout.Toggle(symbol.isOn, GUILayout.Width(checkBoxWidth)); - if(symbol.name == "DEBUG") + if (symbol.name == "DEBUG") { GUILayout.Label(symbol.name + " (Build Olny)", GUILayout.ExpandWidth(false)); } diff --git a/src/EntityTemplate/Editor/EntityTemplateEditor.cs b/src/EntityTemplate/Editor/EntityTemplateEditor.cs index 0963424..833b7fc 100644 --- a/src/EntityTemplate/Editor/EntityTemplateEditor.cs +++ b/src/EntityTemplate/Editor/EntityTemplateEditor.cs @@ -195,7 +195,7 @@ namespace DCFApixels.DragonECS.Unity.Editors else { GUIContent label = UnityEditorUtility.GetLabel(name); - if(componentProperty.propertyType == SerializedPropertyType.Generic) + if (componentProperty.propertyType == SerializedPropertyType.Generic) { EditorGUILayout.PropertyField(componentProperty, label, true); }