mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 10:04:36 +08:00
fixes
This commit is contained in:
parent
d704fa2418
commit
73916a4f8d
@ -130,7 +130,7 @@ namespace DCFApixels.DragonECS
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_isConnectInvoked = false;
|
_isConnectInvoked = false;
|
||||||
if (_entity.TryGetID(out int oldEntityID) && _world != null)
|
if (_world.IsNullOrDetroyed() == false && _entity.TryGetID(out int oldEntityID))
|
||||||
{
|
{
|
||||||
var unityGameObjects = _world.GetPool<GameObjectConnect>();
|
var unityGameObjects = _world.GetPool<GameObjectConnect>();
|
||||||
unityGameObjects.TryDel(oldEntityID);
|
unityGameObjects.TryDel(oldEntityID);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
#endif
|
#endif
|
||||||
@ -87,7 +89,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (_world == null || _world.IsDestroyed)
|
if (_world == null || _world.IsDestroyed)
|
||||||
{
|
{
|
||||||
_world = BuildWorld();
|
Set(BuildWorld());
|
||||||
OnWorldCreated(_world);
|
OnWorldCreated(_world);
|
||||||
}
|
}
|
||||||
return _world;
|
return _world;
|
||||||
|
@ -40,9 +40,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
private void DrawEntityInfo(EcsEntityConnect[] targets)
|
private void DrawEntityInfo(EcsEntityConnect[] targets)
|
||||||
{
|
{
|
||||||
bool isConnected = Target.Entity.TryUnpack(out int id, out short gen, out EcsWorld world);
|
bool isConnected = Target.Entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
|
||||||
EcsGUI.EntityStatus status = IsMultipleTargets ? EcsGUI.EntityStatus.Undefined : isConnected ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive;
|
EcsGUI.EntityStatus status = IsMultipleTargets ? EcsGUI.EntityStatus.Undefined : isConnected ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive;
|
||||||
EcsGUI.Layout.EntityBar(status, id, gen, world.id);
|
EcsGUI.Layout.EntityBar(status, id, gen, worldID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawTemplates()
|
private void DrawTemplates()
|
||||||
@ -116,11 +116,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Target.Entity.TryUnpack(out int entityID, out EcsWorld world))
|
if (Target.Entity.TryUnpackForUnityEditor(out int entityID, out short gen, out short worldID, out EcsWorld world))
|
||||||
|
{
|
||||||
|
if (world.IsNullOrDetroyed() == false)
|
||||||
{
|
{
|
||||||
EcsGUI.Layout.DrawRuntimeComponents(entityID, world);
|
EcsGUI.Layout.DrawRuntimeComponents(entityID, world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -12,17 +12,25 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
public override void OnInspectorGUI()
|
public override void OnInspectorGUI()
|
||||||
{
|
{
|
||||||
if (Target.IsEmpty)
|
EcsWorld world = Target.GetCurrentWorldRaw();
|
||||||
|
if (world == null)
|
||||||
{
|
{
|
||||||
var style = UnityEditorUtility.GetStyle(new Color32(255, 0, 75, 100));
|
var style = UnityEditorUtility.GetStyle(new Color32(255, 0, 75, 100));
|
||||||
GUILayout.Box("Is Empty", style, GUILayout.ExpandWidth(true));
|
GUILayout.Box("Is Empty", style, GUILayout.ExpandWidth(true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (world.IsDestroyed)
|
||||||
|
{
|
||||||
|
var style = UnityEditorUtility.GetStyle(new Color32(255, 75, 0, 100));
|
||||||
|
GUILayout.Box($"{world.GetMeta().Name} ( {world.id} ) Destroyed", style, GUILayout.ExpandWidth(true));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var style = UnityEditorUtility.GetStyle(new Color32(75, 255, 0, 100));
|
var style = UnityEditorUtility.GetStyle(new Color32(75, 255, 0, 100));
|
||||||
EcsWorld world = Target.GetRaw();
|
|
||||||
GUILayout.Box($"{world.GetMeta().Name} ( {world.id} )", style, GUILayout.ExpandWidth(true));
|
GUILayout.Box($"{world.GetMeta().Name} ( {world.id} )", style, GUILayout.ExpandWidth(true));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
EcsGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw());
|
EcsGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw());
|
||||||
|
|
||||||
|
|
||||||
@ -30,9 +38,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
GUILayout.Space(10);
|
GUILayout.Space(10);
|
||||||
|
|
||||||
if (GUILayout.Button("Destroy"))
|
if (GUILayout.Button("Destroy & Clear"))
|
||||||
{
|
{
|
||||||
var w = Target.GetRaw();
|
var w = Target.GetCurrentWorldRaw();
|
||||||
if (w != null && w.IsDestroyed == false)
|
if (w != null && w.IsDestroyed == false)
|
||||||
{
|
{
|
||||||
w.Destroy();
|
w.Destroy();
|
||||||
|
@ -11,8 +11,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
public override void OnInspectorGUI()
|
public override void OnInspectorGUI()
|
||||||
{
|
{
|
||||||
bool isAlive = Target.Entity.TryUnpack(out int id, out short gen, out EcsWorld world);
|
bool isAlive = Target.Entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
|
||||||
EcsGUI.Layout.EntityBar(isAlive ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive, id, gen, world.id);
|
EcsGUI.Layout.EntityBar(isAlive ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive, id, gen, worldID);
|
||||||
EcsGUI.Layout.DrawRuntimeComponents(Target.Entity, false);
|
EcsGUI.Layout.DrawRuntimeComponents(Target.Entity, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,20 +41,28 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
}
|
}
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
|
if (_world == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
TypeMeta meta = _world.GetMeta();
|
TypeMeta meta = _world.GetMeta();
|
||||||
_monitor = new GameObject($"{UnityEditorUtility.TransformToUpperName(meta.Name)} ( {_world.id} )").AddComponent<WorldMonitor>();
|
_monitor = new GameObject($"{UnityEditorUtility.TransformToUpperName(meta.Name)} ( {_world.id} )").AddComponent<WorldMonitor>();
|
||||||
UnityEngine.Object.DontDestroyOnLoad(_monitor);
|
UnityEngine.Object.DontDestroyOnLoad(_monitor);
|
||||||
_monitor.Set(_world);
|
_monitor.Set(_world);
|
||||||
_monitor.gameObject.SetActive(false);
|
_monitor.gameObject.SetActive(false);
|
||||||
|
|
||||||
_entityMonitorsPoolRoot = new GameObject("__POOL").transform;
|
_entityMonitorsPoolRoot = new GameObject("__pool__").transform;
|
||||||
_entityMonitorsPoolRoot.SetParent(_monitor.transform);
|
_entityMonitorsPoolRoot.SetParent(_monitor.transform);
|
||||||
|
|
||||||
|
|
||||||
|
if (_world.IsNullOrDetroyed() == false)
|
||||||
|
{
|
||||||
foreach (var e in _world.Entities)
|
foreach (var e in _world.Entities)
|
||||||
{
|
{
|
||||||
InitNewEntity(e, false);
|
InitNewEntity(e, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IEcsWorldEventListener.OnWorldResize(int newSize)
|
void IEcsWorldEventListener.OnWorldResize(int newSize)
|
||||||
{
|
{
|
||||||
@ -65,8 +73,8 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
{
|
{
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
{
|
{
|
||||||
UnityEngine.Object.Destroy(_monitor);
|
UnityEngine.Object.Destroy(_monitor.gameObject);
|
||||||
UnityEngine.Object.Destroy(_entityMonitorsPoolRoot);
|
UnityEngine.Object.Destroy(_entityMonitorsPoolRoot.gameObject);
|
||||||
}
|
}
|
||||||
_monitor = null;
|
_monitor = null;
|
||||||
_entityMonitorsPoolRoot = null;
|
_entityMonitorsPoolRoot = null;
|
||||||
|
@ -29,7 +29,7 @@ namespace DCFApixels.DragonECS
|
|||||||
bool hasTag = string.IsNullOrEmpty(tag) == false;
|
bool hasTag = string.IsNullOrEmpty(tag) == false;
|
||||||
if (hasTag)
|
if (hasTag)
|
||||||
{
|
{
|
||||||
log = $".[{tag}] {v}";
|
log = $"[{tag}] {v}";
|
||||||
string taglower = tag.ToLower();
|
string taglower = tag.ToLower();
|
||||||
if (taglower.Contains("warning"))
|
if (taglower.Contains("warning"))
|
||||||
{
|
{
|
||||||
|
@ -293,7 +293,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
public static void DrawWorldBaseInfo(EcsWorld world)
|
public static void DrawWorldBaseInfo(EcsWorld world)
|
||||||
{
|
{
|
||||||
bool isNull = world == null || world.id == 0;
|
bool isNull = world == null || world.IsDestroyed || world.id == 0;
|
||||||
int entitesCount = isNull ? 0 : world.Count;
|
int entitesCount = isNull ? 0 : world.Count;
|
||||||
int capacity = isNull ? 0 : world.Capacity;
|
int capacity = isNull ? 0 : world.Capacity;
|
||||||
int leakedEntitesCount = isNull ? 0 : world.CountLeakedEntitesDebug();
|
int leakedEntitesCount = isNull ? 0 : world.CountLeakedEntitesDebug();
|
||||||
@ -321,7 +321,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
public static void DrawRuntimeComponents(entlong entity, bool isWithFoldout = true)
|
public static void DrawRuntimeComponents(entlong entity, bool isWithFoldout = true)
|
||||||
{
|
{
|
||||||
if (entity.TryUnpack(out int entityID, out EcsWorld world))
|
if (entity.TryUnpackForUnityEditor(out int entityID, out _, out _, out EcsWorld world))
|
||||||
{
|
{
|
||||||
DrawRuntimeComponents(entityID, world, isWithFoldout);
|
DrawRuntimeComponents(entityID, world, isWithFoldout);
|
||||||
}
|
}
|
||||||
|
12
src/Internal/EntLongExtentions.cs
Normal file
12
src/Internal/EntLongExtentions.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace DCFApixels.DragonECS.Unity.Internal
|
||||||
|
{
|
||||||
|
internal static class EntLongExtentions
|
||||||
|
{
|
||||||
|
public static bool TryUnpackForUnityEditor(this entlong self, out int id, out short gen, out short worldID, out EcsWorld world)
|
||||||
|
{
|
||||||
|
self.UnpackUnchecked(out id, out gen, out worldID);
|
||||||
|
world = EcsWorld.GetWorld(worldID);
|
||||||
|
return world.IsNullOrDetroyed() == false && self.IsAlive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
src/Internal/EntLongExtentions.cs.meta
Normal file
11
src/Internal/EntLongExtentions.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aac4ee165dbc67241a5291d47a9da9fc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user