com.artromskiy.deltaecs.unity 0.0.64 → 0.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/Editor/HierarchyNodeHandler.cs +20 -31
- package/README.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,7 +19,6 @@ namespace Delta.ECS.Unity.Editor
|
|
|
19
19
|
internal sealed class HierarchyNodeHandler : HierarchyNodeTypeHandler
|
|
20
20
|
{
|
|
21
21
|
private const double RuntimeHierarchyRefreshInterval = 0.5d;
|
|
22
|
-
private static readonly ComponentId[] NoRequiredComponents = Array.Empty<ComponentId>();
|
|
23
22
|
private static readonly SchemaId HiddenEntitySchema = new(ViewComponentSchemaIds.HideFromEntityHierarchy);
|
|
24
23
|
private static double _nextRuntimeHierarchyRefresh;
|
|
25
24
|
private static bool _wasPlaying;
|
|
@@ -32,6 +31,8 @@ namespace Delta.ECS.Unity.Editor
|
|
|
32
31
|
private readonly HashSet<HierarchyView> _boundViews = new();
|
|
33
32
|
private readonly Dictionary<HierarchyView, BlockedDrag> _blockedDrags = new();
|
|
34
33
|
private readonly Dictionary<SceneAuthoring, Action<SceneDataChange>> _sceneDataSubscriptions = new();
|
|
34
|
+
private readonly HashSet<SceneAuthoring> _loadedAuthorings = new();
|
|
35
|
+
private readonly List<SceneAuthoring> _removedAuthorings = new();
|
|
35
36
|
|
|
36
37
|
static HierarchyNodeHandler()
|
|
37
38
|
{
|
|
@@ -98,6 +99,8 @@ namespace Delta.ECS.Unity.Editor
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
_sceneDataSubscriptions.Clear();
|
|
102
|
+
_loadedAuthorings.Clear();
|
|
103
|
+
_removedAuthorings.Clear();
|
|
101
104
|
_entityNodes.Clear();
|
|
102
105
|
_activeEntityKeys.Clear();
|
|
103
106
|
_removedEntityKeys.Clear();
|
|
@@ -594,11 +597,11 @@ namespace Delta.ECS.Unity.Editor
|
|
|
594
597
|
HierarchyNode sceneNode,
|
|
595
598
|
SceneWorld runtimeWorld)
|
|
596
599
|
{
|
|
597
|
-
Query query = runtimeWorld.World.WhereNone(runtimeWorld.HiddenEntityHierarchyComponentId)
|
|
598
|
-
.WhereAll(NoRequiredComponents);
|
|
600
|
+
Query query = runtimeWorld.World.WhereNone(runtimeWorld.HiddenEntityHierarchyComponentId);
|
|
599
601
|
bool changed = false;
|
|
600
|
-
runtimeWorld.World.ForEachEntity(in query,
|
|
602
|
+
runtimeWorld.World.ForEachEntity(in query, entityRef =>
|
|
601
603
|
{
|
|
604
|
+
Entity entity = entityRef;
|
|
602
605
|
if (runtimeWorld.TryGetStableId(entity, out _) || runtimeWorld.TryGetView(entity, out _))
|
|
603
606
|
{
|
|
604
607
|
return;
|
|
@@ -606,29 +609,13 @@ namespace Delta.ECS.Unity.Editor
|
|
|
606
609
|
|
|
607
610
|
var key = new EntityKey(runtimeWorld, entity);
|
|
608
611
|
_activeEntityKeys.Add(key);
|
|
609
|
-
|
|
610
|
-
var reference = new NodeReference(authoring, null, runtimeWorld, entity);
|
|
611
|
-
if (_entityNodes.TryGetValue(key, out EntityNode entityNode))
|
|
612
|
+
if (_entityNodes.ContainsKey(key))
|
|
612
613
|
{
|
|
613
|
-
if (entityNode.Reference.RuntimeWorld != reference.RuntimeWorld
|
|
614
|
-
|| entityNode.Reference.RuntimeEntity != reference.RuntimeEntity)
|
|
615
|
-
{
|
|
616
|
-
entityNode.Reference = reference;
|
|
617
|
-
changed = true;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
if (!string.Equals(entityNode.Name, name, StringComparison.Ordinal))
|
|
621
|
-
{
|
|
622
|
-
CommandList.SetName(entityNode.Node, name);
|
|
623
|
-
entityNode.Name = name;
|
|
624
|
-
changed = true;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
_entityNodes[key] = entityNode;
|
|
628
|
-
_nodes[entityNode.Node] = reference;
|
|
629
614
|
return;
|
|
630
615
|
}
|
|
631
616
|
|
|
617
|
+
string name = $"ECS Entity {entity.Index}:{entity.Generation}";
|
|
618
|
+
var reference = new NodeReference(authoring, null, runtimeWorld, entity);
|
|
632
619
|
CommandList.Add(sceneNode, out HierarchyNode node);
|
|
633
620
|
CommandList.SetName(node, name);
|
|
634
621
|
_entityNodes.Add(key, new EntityNode(node, reference, name));
|
|
@@ -641,7 +628,7 @@ namespace Delta.ECS.Unity.Editor
|
|
|
641
628
|
|
|
642
629
|
private void SynchronizeSceneSubscriptions(SceneAuthoring[] authorings)
|
|
643
630
|
{
|
|
644
|
-
|
|
631
|
+
_loadedAuthorings.Clear();
|
|
645
632
|
for (var i = 0; i < authorings.Length; i++)
|
|
646
633
|
{
|
|
647
634
|
var authoring = authorings[i];
|
|
@@ -650,7 +637,7 @@ namespace Delta.ECS.Unity.Editor
|
|
|
650
637
|
continue;
|
|
651
638
|
}
|
|
652
639
|
|
|
653
|
-
|
|
640
|
+
_loadedAuthorings.Add(authoring);
|
|
654
641
|
if (!_sceneDataSubscriptions.ContainsKey(authoring))
|
|
655
642
|
{
|
|
656
643
|
var capturedAuthoring = authoring;
|
|
@@ -660,29 +647,31 @@ namespace Delta.ECS.Unity.Editor
|
|
|
660
647
|
}
|
|
661
648
|
}
|
|
662
649
|
|
|
663
|
-
if (_sceneDataSubscriptions.Count ==
|
|
650
|
+
if (_sceneDataSubscriptions.Count == _loadedAuthorings.Count)
|
|
664
651
|
{
|
|
665
652
|
return;
|
|
666
653
|
}
|
|
667
654
|
|
|
668
|
-
|
|
655
|
+
_removedAuthorings.Clear();
|
|
669
656
|
foreach (var authoring in _sceneDataSubscriptions.Keys)
|
|
670
657
|
{
|
|
671
|
-
if (!
|
|
658
|
+
if (!_loadedAuthorings.Contains(authoring))
|
|
672
659
|
{
|
|
673
|
-
|
|
660
|
+
_removedAuthorings.Add(authoring);
|
|
674
661
|
}
|
|
675
662
|
}
|
|
676
663
|
|
|
677
|
-
for (var i = 0; i <
|
|
664
|
+
for (var i = 0; i < _removedAuthorings.Count; i++)
|
|
678
665
|
{
|
|
679
|
-
var authoring =
|
|
666
|
+
var authoring = _removedAuthorings[i];
|
|
680
667
|
if (authoring != null)
|
|
681
668
|
{
|
|
682
669
|
authoring.SceneData.Changed -= _sceneDataSubscriptions[authoring];
|
|
683
670
|
}
|
|
684
671
|
_sceneDataSubscriptions.Remove(authoring);
|
|
685
672
|
}
|
|
673
|
+
|
|
674
|
+
_removedAuthorings.Clear();
|
|
686
675
|
}
|
|
687
676
|
|
|
688
677
|
private void OnSceneDataChanged(SceneAuthoring authoring, SceneDataChange change)
|
package/README.md
CHANGED