DragonECS-Unity/src/DebugUtils/Monitors/Editor/EntityMonitorEditor.cs

55 lines
1.9 KiB
C#
Raw Normal View History

2024-03-10 04:56:29 +08:00
#if UNITY_EDITOR
using DCFApixels.DragonECS.Unity.Internal;
using UnityEditor;
using UnityEngine;
2024-03-10 04:56:29 +08:00
namespace DCFApixels.DragonECS.Unity.Editors
{
[CustomEditor(typeof(EntityMonitor))]
internal class EntityMonitorEditor : ExtendedEditor<EntityMonitor>
2024-03-10 04:56:29 +08:00
{
protected override void DrawCustom()
2024-03-10 04:56:29 +08:00
{
2025-03-10 13:08:18 +08:00
var entity = Target.Entity;
bool isAlive = entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
using (EcsGUI.SetEnable(isAlive))
{
2024-05-16 19:03:03 +08:00
if (GUILayout.Button("Delete Entity", GUILayout.Height(36f)))
{
world.DelEntity(id);
}
}
2025-04-16 09:36:51 +08:00
//EcsGUI.Layout.EntityBarForAlive(isAlive ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive, id, gen, worldID);
EcsGUI.Layout.EntityField(entity);
2025-03-10 13:08:18 +08:00
var drawers = UnityEditorUtility._entityEditorBlockDrawers;
if (drawers.Length > 0)
{
2025-03-10 17:56:18 +08:00
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
2025-03-10 13:08:18 +08:00
{
bool isExpand = false;
using (EcsGUI.CheckChanged())
{
isExpand = EditorGUILayout.Foldout(UserSettingsPrefs.instance.IsShowEntityOtherData, "Other data");
if (EcsGUI.Changed)
{
UserSettingsPrefs.instance.IsShowEntityOtherData = isExpand;
}
}
if (isExpand)
{
foreach (var drawer in drawers)
{
drawer.Draw(entity);
}
}
}
2025-03-10 17:56:18 +08:00
2025-03-10 13:08:18 +08:00
}
2025-03-10 17:56:18 +08:00
2025-03-10 13:08:18 +08:00
EcsGUI.Layout.DrawRuntimeComponents(entity, false);
2024-03-10 04:56:29 +08:00
}
}
}
#endif