com.artromskiy.deltaecs.unity 0.0.60 → 0.0.62

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.62
4
+
5
+ - Published with the matching DeltaECS NuGet packages.
6
+
7
+ ## 0.0.61
8
+
9
+ - Published with the matching DeltaECS NuGet packages.
10
+
3
11
  ## 0.0.60
4
12
 
5
13
  - Published with the matching DeltaECS NuGet packages.
@@ -20,6 +20,7 @@ namespace Delta.ECS.Unity.Editor
20
20
  {
21
21
  private const double RuntimeHierarchyRefreshInterval = 0.5d;
22
22
  private static readonly ComponentId[] NoRequiredComponents = Array.Empty<ComponentId>();
23
+ private static readonly SchemaId HiddenEntitySchema = new(ViewComponentSchemaIds.HideFromEntityHierarchy);
23
24
  private static double _nextRuntimeHierarchyRefresh;
24
25
  private static bool _wasPlaying;
25
26
  private static readonly HashSet<HierarchyNodeHandler> Instances = new();
@@ -269,6 +270,30 @@ namespace Delta.ECS.Unity.Editor
269
270
  return true;
270
271
  }
271
272
 
273
+ private static bool IsHiddenFromHierarchy(
274
+ EntityAuthoring authoring,
275
+ SceneWorld runtimeWorld,
276
+ Entity runtimeEntity)
277
+ {
278
+ if (runtimeWorld != null && runtimeWorld.World.IsAlive(runtimeEntity))
279
+ {
280
+ return runtimeWorld.World.Has(runtimeEntity, runtimeWorld.HiddenEntityHierarchyComponentId);
281
+ }
282
+
283
+ IList<ComponentData> components = authoring.Components;
284
+ for (int index = 0; index < components.Count; index++)
285
+ {
286
+ if (components[index] != null
287
+ && components[index].TryGetSchemaId(out SchemaId schema)
288
+ && schema == HiddenEntitySchema)
289
+ {
290
+ return true;
291
+ }
292
+ }
293
+
294
+ return false;
295
+ }
296
+
272
297
  private void BindToView(HierarchyView view) => OnBindView(view);
273
298
 
274
299
  private void OnEntityNameChanged(ChangeEvent<string> evt)
@@ -458,7 +483,7 @@ namespace Delta.ECS.Unity.Editor
458
483
  || (runtimeWorld != null
459
484
  && runtimeWorld.World.IsAlive(runtimeEntity)
460
485
  && runtimeWorld.TryGetView(runtimeEntity, out _));
461
- if (hasView)
486
+ if (hasView || IsHiddenFromHierarchy(authoring, runtimeWorld, runtimeEntity))
462
487
  {
463
488
  continue;
464
489
  }
@@ -569,7 +594,8 @@ namespace Delta.ECS.Unity.Editor
569
594
  HierarchyNode sceneNode,
570
595
  SceneWorld runtimeWorld)
571
596
  {
572
- Query query = runtimeWorld.World.WhereAll(NoRequiredComponents);
597
+ Query query = runtimeWorld.World.WhereNone(runtimeWorld.HiddenEntityHierarchyComponentId)
598
+ .WhereAll(NoRequiredComponents);
573
599
  bool changed = false;
574
600
  runtimeWorld.World.ForEachEntity(in query, entity =>
575
601
  {
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.60"
21
+ "com.artromskiy.deltaecs.unity": "0.0.62"
22
22
  }
23
23
  }
24
24
  ```
@@ -29,9 +29,11 @@ namespace Delta.ECS.Unity
29
29
  private readonly SceneData _sceneData;
30
30
  private readonly SceneAuthoring _authoring;
31
31
  private readonly bool _ownsWorld;
32
+ private readonly ComponentId _hiddenEntityHierarchyComponentId;
32
33
  private bool _disposed;
33
34
 
34
35
  public World World => _world;
36
+ internal ComponentId HiddenEntityHierarchyComponentId => _hiddenEntityHierarchyComponentId;
35
37
 
36
38
  public Entity[] AuthoredEntities
37
39
  {
@@ -60,6 +62,7 @@ namespace Delta.ECS.Unity
60
62
  _authoring = authoring;
61
63
  _integration = world;
62
64
  _ownsWorld = ownsWorld;
65
+ _hiddenEntityHierarchyComponentId = world.Components.GetPrimary<HideFromEntityHierarchy>();
63
66
 
64
67
  _sceneData.EnsureStableIds();
65
68
  _integration.Initialize();
@@ -570,6 +573,7 @@ namespace Delta.ECS.Unity
570
573
  private static World CreateWorld(int initialEntityCapacity)
571
574
  {
572
575
  var layouts = new ComponentRegistry();
576
+ layouts.Register<HideFromEntityHierarchy>(new SchemaId(ViewComponentSchemaIds.HideFromEntityHierarchy));
573
577
  foreach (IGeneratedComponentRegistration registration in GeneratedComponentCatalog.GetRegistrations())
574
578
  {
575
579
  layouts.Register(registration);
@@ -2,6 +2,13 @@ using Delta.ECS;
2
2
 
3
3
  namespace Delta.ECS.Unity
4
4
  {
5
+ internal static class ViewComponentSchemaIds
6
+ {
7
+ internal const ulong ViewToken = 0x405B11F5A17E14A1UL;
8
+ internal const ulong ViewBound = 0xB31CB42A81D3B164UL;
9
+ internal const ulong HideFromEntityHierarchy = 0x8C13A2E9764DB501UL;
10
+ }
11
+
5
12
  /// <summary>Receives the entity context after a Unity view is bound to an entity.</summary>
6
13
  public interface IEntityView
7
14
  {
@@ -10,7 +17,7 @@ namespace Delta.ECS.Unity
10
17
  }
11
18
 
12
19
  /// <summary>Selects the Unity prefab used to represent an entity.</summary>
13
- [ComponentSchema(0x405B11F5A17E14A1UL)]
20
+ [ComponentSchema(ViewComponentSchemaIds.ViewToken)]
14
21
  public readonly struct ViewToken
15
22
  {
16
23
  /// <summary>Gets the identifier of the view prefab in a <see cref="ViewPrefabCatalog"/>.</summary>
@@ -21,8 +28,15 @@ namespace Delta.ECS.Unity
21
28
  }
22
29
 
23
30
  /// <summary>Marks an entity whose Unity view has already been bound.</summary>
24
- [ComponentSchema(0xB31CB42A81D3B164UL)]
31
+ [ComponentSchema(ViewComponentSchemaIds.ViewBound)]
25
32
  public struct ViewBound
26
33
  {
27
34
  }
35
+
36
+ /// <summary>Hides an unbound ECS entity from the Unity Hierarchy window while this tag is present.</summary>
37
+ /// <remarks>Entities bound to a GameObject keep their normal Unity hierarchy visibility.</remarks>
38
+ [ComponentSchema(ViewComponentSchemaIds.HideFromEntityHierarchy)]
39
+ public readonly struct HideFromEntityHierarchy
40
+ {
41
+ }
28
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.artromskiy.deltaecs.unity",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "displayName": "DeltaECS Unity",
5
5
  "description": "Unity scene authoring and editor integration for DeltaECS.",
6
6
  "unity": "6000.7",