com.artromskiy.deltaecs.unity 0.0.63 → 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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.65
4
+
5
+ - Published with the matching DeltaECS NuGet packages.
6
+
7
+ ## 0.0.64
8
+
9
+ - Published with the matching DeltaECS NuGet packages.
10
+
3
11
  ## 0.0.63
4
12
 
5
13
  - Published with the matching DeltaECS NuGet packages.
@@ -3,7 +3,6 @@ using System.Collections.Generic;
3
3
  using System.Linq;
4
4
  using System.Reflection;
5
5
 
6
-
7
6
  using UnityEditor.IMGUI.Controls;
8
7
 
9
8
  using UnityEngine;
@@ -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, entity =>
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
- string name = $"ECS Entity {entity.Index}:{entity.Generation}";
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
- var loadedAuthorings = new HashSet<SceneAuthoring>();
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
- loadedAuthorings.Add(authoring);
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 == loadedAuthorings.Count)
650
+ if (_sceneDataSubscriptions.Count == _loadedAuthorings.Count)
664
651
  {
665
652
  return;
666
653
  }
667
654
 
668
- var removed = new List<SceneAuthoring>();
655
+ _removedAuthorings.Clear();
669
656
  foreach (var authoring in _sceneDataSubscriptions.Keys)
670
657
  {
671
- if (!loadedAuthorings.Contains(authoring))
658
+ if (!_loadedAuthorings.Contains(authoring))
672
659
  {
673
- removed.Add(authoring);
660
+ _removedAuthorings.Add(authoring);
674
661
  }
675
662
  }
676
663
 
677
- for (var i = 0; i < removed.Count; i++)
664
+ for (var i = 0; i < _removedAuthorings.Count; i++)
678
665
  {
679
- var authoring = removed[i];
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)
@@ -34,6 +34,8 @@ namespace Delta.ECS.Unity.Editor
34
34
  internal int ComponentCount => _componentEntries.Count;
35
35
  private SceneAuthoring Authoring => _target.Authoring;
36
36
 
37
+ private ComponentRegistry Components => (_target.IsRuntime ? _target.RuntimeWorld : _previewWorld).World.Components;
38
+
37
39
  public SceneEntityInspectorView(SelectionProxy proxy)
38
40
  : this(() => proxy != null ? proxy.Target : default)
39
41
  {
@@ -190,18 +192,6 @@ namespace Delta.ECS.Unity.Editor
190
192
 
191
193
  private static Label CreateEntityIcon() => CreateClassLabel("◆", "ecs-entity-icon");
192
194
 
193
- private ComponentRegistry Components => (_target.IsRuntime ? _target.RuntimeWorld : _previewWorld).World.Components;
194
-
195
- private ComponentId? TryGetComponentId(ComponentData data)
196
- => _previewWorld.TryGetComponentId(data, out ComponentId componentId) ? componentId : null;
197
-
198
- private string GetComponentMenuPath(ComponentId componentId)
199
- {
200
- string namespacePath = Components.GetComponentType(componentId).Namespace?.Replace('.', '/') ?? string.Empty;
201
- string shortName = GetShortTypeName(Components.GetComponentType(componentId));
202
- return string.IsNullOrEmpty(namespacePath) ? shortName : $"{namespacePath}/{shortName}";
203
- }
204
-
205
195
  private static string GetShortTypeName(Type type)
206
196
  {
207
197
  string name = type.Name;
@@ -223,6 +213,16 @@ namespace Delta.ECS.Unity.Editor
223
213
  private static int GetComponentOrder(ulong schema) =>
224
214
  InspectorState.instance.GetComponentOrder(schema);
225
215
 
216
+ private ComponentId? TryGetComponentId(ComponentData data)
217
+ => _previewWorld.TryGetComponentId(data, out ComponentId componentId) ? componentId : null;
218
+
219
+ private string GetComponentMenuPath(ComponentId componentId)
220
+ {
221
+ string namespacePath = Components.GetComponentType(componentId).Namespace?.Replace('.', '/') ?? string.Empty;
222
+ string shortName = GetShortTypeName(Components.GetComponentType(componentId));
223
+ return string.IsNullOrEmpty(namespacePath) ? shortName : $"{namespacePath}/{shortName}";
224
+ }
225
+
226
226
  private void OnEntitySelectionChanged()
227
227
  {
228
228
  SyncSelection();
package/README.md CHANGED
@@ -18,7 +18,7 @@ Add the npm-compatible registry and package to the Unity project's
18
18
  }
19
19
  ],
20
20
  "dependencies": {
21
- "com.artromskiy.deltaecs.unity": "0.0.63"
21
+ "com.artromskiy.deltaecs.unity": "0.0.65"
22
22
  }
23
23
  }
24
24
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.artromskiy.deltaecs.unity",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "displayName": "DeltaECS Unity",
5
5
  "description": "Unity scene authoring and editor integration for DeltaECS.",
6
6
  "unity": "6000.7",