add Delete Entity button to EntityMonitor

This commit is contained in:
Mikhail 2024-05-13 19:27:53 +08:00
parent 6ad3668114
commit 1e3b5136c6
3 changed files with 9 additions and 2 deletions

View File

@ -11,7 +11,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
{
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);

View File

@ -1,6 +1,7 @@
#if UNITY_EDITOR
using DCFApixels.DragonECS.Unity.Internal;
using UnityEditor;
using UnityEngine;
namespace DCFApixels.DragonECS.Unity.Editors
{
@ -12,6 +13,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
public override void OnInspectorGUI()
{
bool isAlive = Target.Entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
using (new EditorGUI.DisabledScope(!isAlive))
{
if (GUILayout.Button("Delete Entity"))
{
world.DelEntity(id);
}
}
EcsGUI.Layout.EntityBarForAlive(isAlive ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive, id, gen, worldID);
EcsGUI.Layout.DrawRuntimeComponents(Target.Entity, false);
}