This commit is contained in:
CortexCore
2024-06-18 17:57:21 +08:00
parent 82294e44ee
commit d3fd104900
10 changed files with 105 additions and 43 deletions

View File

@@ -18,9 +18,12 @@ namespace BITKit.Entities
public class Entity : MonoBehaviour, IUnityEntity
{
private readonly GenericEvent genericEvent = new();
public int Id { get; set; }
[SerializeField,ReadOnly] private int id;
public int Id
{
get => id;
set => id = value;
}
public CancellationToken CancellationToken { get; private set; }
public IEntityBehavior[] Behaviors { get;private set; }
public IEntityComponent[] Components => Behaviors.Cast<IEntityComponent>().ToArray();
@@ -251,18 +254,18 @@ namespace BITKit.Entities
public void Set<T>(T value) => genericEvent.Set<T>(value);
public void Set<T>(string key = Constant.System.Internal, T value = default) => genericEvent.Set<T>(key, value);
}
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(Entity))]
public class EntityInspector : BITInspector<Entity>
{
public override VisualElement CreateInspectorGUI()
{
FillDefaultInspector();
CreateSubTitle("Identity");
var idLabel = root.Create<Label>();
idLabel.text = agent.Id.ToString();
return root;
}
}
#endif
// #if UNITY_EDITOR
// [UnityEditor.CustomEditor(typeof(Entity))]
// public class EntityInspector : BITInspector<Entity>
// {
// public override VisualElement CreateInspectorGUI()
// {
// FillDefaultInspector();
// CreateSubTitle("Identity");
// var idLabel = root.Create<Label>();
// idLabel.text = agent.Id.ToString();
// return root;
// }
// }
// #endif
}