add EntityDrawer

This commit is contained in:
Mikhail 2024-05-13 18:21:51 +08:00
parent 2b216bedb1
commit 5dfe28e87d
4 changed files with 41 additions and 4 deletions

View File

@ -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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 614e6caafa5d5724fbb3324ea3a60194
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -51,7 +51,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
using (new EcsGUI.ColorScope(Color.white * 0.5f)) using (new EcsGUI.ColorScope(Color.white * 0.5f))
GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.BeginVertical(EditorStyles.helpBox);
//using (new EcsGUI.ColorScope(Color.white * 1.2f)) //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 rect = GUILayoutUtility.GetLastRect();
rect.xMin += 9f; rect.xMin += 9f;
GUI.Label(rect, "Settings", EditorStyles.whiteLargeLabel); GUI.Label(rect, "Settings", EditorStyles.whiteLargeLabel);
@ -87,7 +87,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
using (new EcsGUI.ColorScope(Color.white * 0.5f)) using (new EcsGUI.ColorScope(Color.white * 0.5f))
GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.BeginVertical(EditorStyles.helpBox);
//using (new EcsGUI.ColorScope(Color.white * 1.2f)) //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 = GUILayoutUtility.GetLastRect();
rect.xMin += 9f; rect.xMin += 9f;
GUI.Label(rect, "Scripting Define Symbols", EditorStyles.whiteLargeLabel); GUI.Label(rect, "Scripting Define Symbols", EditorStyles.whiteLargeLabel);
@ -101,7 +101,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
var symbol = _defineSymbols[i]; var symbol = _defineSymbols[i];
symbol.isOn = EditorGUILayout.Toggle(symbol.isOn, GUILayout.Width(checkBoxWidth)); 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)); GUILayout.Label(symbol.name + " (Build Olny)", GUILayout.ExpandWidth(false));
} }

View File

@ -195,7 +195,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
else else
{ {
GUIContent label = UnityEditorUtility.GetLabel(name); GUIContent label = UnityEditorUtility.GetLabel(name);
if(componentProperty.propertyType == SerializedPropertyType.Generic) if (componentProperty.propertyType == SerializedPropertyType.Generic)
{ {
EditorGUILayout.PropertyField(componentProperty, label, true); EditorGUILayout.PropertyField(componentProperty, label, true);
} }