From 0783fbd7a95eaa8cc0e425d3925760ec9564ab0a Mon Sep 17 00:00:00 2001 From: Unity Technologies <@unity> Date: Tue, 13 Feb 2024 00:00:00 +0000 Subject: [PATCH] com.unity.entities@1.2.0-pre.12 ## [1.2.0-pre.12] - 2024-02-13 ### Added * A file with the code for both snippets in the custom transforms documentation was added to the "DocCodeSamples.Tests" folder. * The Create Menu now offers ScriptTemplates for the IComponentData, ISystem, IJobEntity and Baker types under Assets/Create/Entities ### Changed * Fixed infinite loop that could occur due to concurrent use of non-concurrent Dictionary in Aspect Generator. * Reduce the set/restore frequency of the fixed rate system group allocator. * Various performance improvements in baking. Baking mesh-heavy scenes now takes 70% of what it did before. * Significant performance improvements when creating archetypes and entity queries in Worlds with a large number of existing archetypes/queries. * Updated Burst dependency to version 1.8.12 ### Fixed * EntityQuery singleton methods now correctly handle cases where the query contains enableable components. Note that `GetSingletonEntity()` and `TryGetSingletonEntity()` still can not be used on queries with enableable components, and that the singleton component itself can not be enableable. Both constraints may be lifted in a future release. * A broken link to a code snippet in the documentation for custom transforms was fixed. * Archetype window and Entity Memory Profiler module UI initialization. * Making a player build with define `UNITY_DOTS_DEBUG`, while using an IJobEntity using RefRO/RefRW no longer compile errors! * Clarified documentation for cleanup components * Fixed minor memory leak in content delivery system. * AABB.Contains. * The entities hierarchy view would sometimes throw exceptions when entities were destroyed. * remove use of UNITY_64 define, as is can not be reliably used to determine 64 bit nature of platforms. Fixes crashes related to pointer truncation. --- CHANGELOG.md | 29 +- DocCodeSamples.Tests/TransformsCustom.cs | 62 ++++ DocCodeSamples.Tests/TransformsCustom.cs.meta | 11 + Documentation~/baking-overview.md | 2 +- Documentation~/baking.md | 2 +- .../components-cleanup-introducing.md | 7 +- Documentation~/components-cleanup-shared.md | 2 +- Documentation~/components-nativecontainers.md | 2 +- Documentation~/index.md | 7 +- Documentation~/transforms-custom.md | 41 +-- .../memory-profiler-left-pane.uss | 4 + .../structural-changes-profiler-window.uss | 4 + .../memory-profiler-left-pane.uxml | 2 +- .../structural-changes-profiler-window.uxml | 2 +- LICENSE.md | 2 +- .../ScriptTemplates.meta | 8 + .../ScriptTemplates/ScriptTemplatesTests.cs | 28 ++ .../ScriptTemplatesTests.cs.meta | 11 + .../HierarchyEntityChangeTracker.cs | 108 +++++- .../Model/HierarchyNodeStore+Immutable.cs | 53 ++- .../Hierarchy/Utility/EntityMapDense.cs | 102 ++++-- .../MemoryProfilerModule+View.cs | 6 +- .../StructuralChangesProfilerModule+View.cs | 7 +- Unity.Entities.Editor/ScriptTemplates.meta | 8 + .../ScriptTemplates/BakerTemplate.txt | 17 + .../ScriptTemplates/BakerTemplate.txt.meta | 7 + .../IComponentDataTemplate.txt | 8 + .../IComponentDataTemplate.txt.meta | 7 + .../ScriptTemplates/IJobEntityTemplate.txt | 11 + .../IJobEntityTemplate.txt.meta | 7 + .../ScriptTemplates/ISystemTemplate.txt | 25 ++ .../ScriptTemplates/ISystemTemplate.txt.meta | 7 + .../ScriptTemplates/ScriptTemplates.cs | 33 ++ .../ScriptTemplates/ScriptTemplates.cs.meta | 11 + .../CompanionComponentPerformanceTests.cs | 30 +- .../Baking/BakedEntityData.cs | 94 ++--- Unity.Entities.Hybrid/Baking/Baker.cs | 70 ++++ .../Baking/BakingAnalytics.cs | 5 +- Unity.Entities.Hybrid/Baking/BakingSystem.cs | 12 +- .../Baking/IncrementalBakingContext.cs | 16 +- .../Incremental/IncrementalHierarchy.cs | 1 + .../EntityQueryPerformanceTests.cs | 32 ++ .../PrefabAuthoring.cs | 18 + .../PrefabAuthoring.cs.meta | 3 + .../EntityArchetypeQueryTests.cs | 94 +++++ Unity.Entities.Tests/EntityQueryTests.cs | 2 - Unity.Entities.Tests/SingletonTests.cs | 110 ++++++ .../SystemGroupAllocatorTests.cs | 322 ++++++++++++------ Unity.Entities/Blobs.cs | 34 +- .../Delivery/ContentDeliveryGlobalState.cs | 1 + .../Delivery/ContentDeliveryService.cs | 10 +- Unity.Entities/EntityComponentStore.cs | 3 + Unity.Entities/IComponentData.cs | 15 + .../Internal/InternalCompilerInterface.cs | 65 ++-- .../Iterators/ChunkIterationUtility.cs | 105 ++++++ Unity.Entities/Iterators/EntityQuery.cs | 81 ++--- .../Iterators/EntityQueryManager.cs | 247 +++++++------- Unity.Entities/RateUtils.cs | 20 +- .../SourceGenerators/AspectGenerator.dll | Bin 84992 -> 85504 bytes .../SourceGenerators/AspectGenerator.pdb | Bin 25496 -> 25492 bytes Unity.Entities/SourceGenerators/Common.dll | Bin 43008 -> 43008 bytes Unity.Entities/SourceGenerators/Common.pdb | Bin 18864 -> 18864 bytes .../SourceGenerators/JobEntityGenerator.dll | Bin 81408 -> 81408 bytes .../SourceGenerators/JobEntityGenerator.pdb | Bin 24520 -> 24516 bytes .../AspectGenerator/AspectGenerator.cs | 4 +- .../SystemGenerator.Common.dll | Bin 54272 -> 54272 bytes .../SystemGenerator.Common.pdb | Bin 23196 -> 23192 bytes ...temGenerator.EntityQueryBulkOperations.dll | Bin 15360 -> 15360 bytes ...temGenerator.EntityQueryBulkOperations.pdb | Bin 10876 -> 10872 bytes .../SystemGenerator.LambdaJobs.dll | Bin 148480 -> 147968 bytes .../SystemGenerator.LambdaJobs.pdb | Bin 40616 -> 40608 bytes .../SystemGenerator.SystemAPI.Query.dll | Bin 67072 -> 67072 bytes .../SystemGenerator.SystemAPI.Query.pdb | Bin 21780 -> 21772 bytes ...SystemGenerator.SystemAPI.QueryBuilder.dll | Bin 25088 -> 25088 bytes ...SystemGenerator.SystemAPI.QueryBuilder.pdb | Bin 13348 -> 13344 bytes .../SystemGenerator.SystemAPI.dll | Bin 31744 -> 31232 bytes .../SystemGenerator.SystemAPI.pdb | Bin 14296 -> 14292 bytes .../SourceGenerators/SystemGenerator.dll | Bin 19968 -> 19968 bytes .../SourceGenerators/SystemGenerator.pdb | Bin 12908 -> 12908 bytes .../Unity.Entities.Analyzer.CodeFixes.dll | Bin 18944 -> 18944 bytes .../Unity.Entities.Analyzer.CodeFixes.pdb | Bin 11492 -> 11488 bytes .../Unity.Entities.Analyzer.dll | Bin 30208 -> 29696 bytes .../Unity.Entities.Analyzer.pdb | Bin 13776 -> 13772 bytes Unity.Entities/Types/Archetype.cs | 1 + Unity.Entities/Types/TypeManager.cs | 46 ++- Unity.Mathematics.Extensions.Tests.meta | 8 + .../MathTests.cs | 70 ++++ .../MathTests.cs.meta | 11 + .../Unity.Mathematics.Extensions.Tests.asmdef | 23 ++ ...y.Mathematics.Extensions.Tests.asmdef.meta | 7 + Unity.Mathematics.Extensions/AABB.cs | 12 +- .../LiveConversionEditorTests.cs | 88 ++++- .../Content/RuntimeContentManagerTests.cs | 11 +- ValidationExceptions.json | 2 +- ValidationExceptions.json.meta | 2 +- package.json | 12 +- 96 files changed, 1805 insertions(+), 525 deletions(-) create mode 100644 DocCodeSamples.Tests/TransformsCustom.cs create mode 100644 DocCodeSamples.Tests/TransformsCustom.cs.meta create mode 100644 Unity.Entities.Editor.Tests/ScriptTemplates.meta create mode 100644 Unity.Entities.Editor.Tests/ScriptTemplates/ScriptTemplatesTests.cs create mode 100644 Unity.Entities.Editor.Tests/ScriptTemplates/ScriptTemplatesTests.cs.meta create mode 100644 Unity.Entities.Editor/ScriptTemplates.meta create mode 100644 Unity.Entities.Editor/ScriptTemplates/BakerTemplate.txt create mode 100644 Unity.Entities.Editor/ScriptTemplates/BakerTemplate.txt.meta create mode 100644 Unity.Entities.Editor/ScriptTemplates/IComponentDataTemplate.txt create mode 100644 Unity.Entities.Editor/ScriptTemplates/IComponentDataTemplate.txt.meta create mode 100644 Unity.Entities.Editor/ScriptTemplates/IJobEntityTemplate.txt create mode 100644 Unity.Entities.Editor/ScriptTemplates/IJobEntityTemplate.txt.meta create mode 100644 Unity.Entities.Editor/ScriptTemplates/ISystemTemplate.txt create mode 100644 Unity.Entities.Editor/ScriptTemplates/ISystemTemplate.txt.meta create mode 100644 Unity.Entities.Editor/ScriptTemplates/ScriptTemplates.cs create mode 100644 Unity.Entities.Editor/ScriptTemplates/ScriptTemplates.cs.meta create mode 100644 Unity.Entities.TestComponents/PrefabAuthoring.cs create mode 100644 Unity.Entities.TestComponents/PrefabAuthoring.cs.meta create mode 100644 Unity.Mathematics.Extensions.Tests.meta create mode 100644 Unity.Mathematics.Extensions.Tests/MathTests.cs create mode 100644 Unity.Mathematics.Extensions.Tests/MathTests.cs.meta create mode 100644 Unity.Mathematics.Extensions.Tests/Unity.Mathematics.Extensions.Tests.asmdef create mode 100644 Unity.Mathematics.Extensions.Tests/Unity.Mathematics.Extensions.Tests.asmdef.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index 4385e611..2fb123a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,33 @@ uid: changelog --- -# Changelog +## [1.2.0-pre.12] - 2024-02-13 + +### Added + +* A file with the code for both snippets in the custom transforms documentation was added to the "DocCodeSamples.Tests" folder. +* The Create Menu now offers ScriptTemplates for the IComponentData, ISystem, IJobEntity and Baker types under Assets/Create/Entities + +### Changed + +* Fixed infinite loop that could occur due to concurrent use of non-concurrent Dictionary in Aspect Generator. +* Reduce the set/restore frequency of the fixed rate system group allocator. +* Various performance improvements in baking. Baking mesh-heavy scenes now takes 70% of what it did before. +* Significant performance improvements when creating archetypes and entity queries in Worlds with a large number of existing archetypes/queries. +* Updated Burst dependency to version 1.8.12 + +### Fixed + +* EntityQuery singleton methods now correctly handle cases where the query contains enableable components. Note that `GetSingletonEntity()` and `TryGetSingletonEntity()` still can not be used on queries with enableable components, and that the singleton component itself can not be enableable. Both constraints may be lifted in a future release. +* A broken link to a code snippet in the documentation for custom transforms was fixed. +* Archetype window and Entity Memory Profiler module UI initialization. +* Making a player build with define `UNITY_DOTS_DEBUG`, while using an IJobEntity using RefRO/RefRW no longer compile errors! +* Clarified documentation for cleanup components +* Fixed minor memory leak in content delivery system. +* AABB.Contains. +* The entities hierarchy view would sometimes throw exceptions when entities were destroyed. +* remove use of UNITY_64 define, as is can not be reliably used to determine 64 bit nature of platforms. Fixes crashes related to pointer truncation. + ## [1.2.0-pre.6] - 2023-12-13 @@ -28,6 +54,7 @@ uid: changelog * Selecting entities and systems now works again. + ## [1.2.0-exp.3] - 2023-11-09 ### Added diff --git a/DocCodeSamples.Tests/TransformsCustom.cs b/DocCodeSamples.Tests/TransformsCustom.cs new file mode 100644 index 00000000..891ffd32 --- /dev/null +++ b/DocCodeSamples.Tests/TransformsCustom.cs @@ -0,0 +1,62 @@ +using System.Globalization; +using UnityEngine; +using Unity.Entities; +using Unity.Mathematics; +using Unity.Transforms; + +namespace Miscellaneous.CustomTransforms +{ + #region Transform2DAuthoring + public class Transform2DAuthoring : MonoBehaviour + { + class Baker : Baker + { + public override void Bake(Transform2DAuthoring authoring) + { + // Ensure that no standard transform components are added. + var entity = GetEntity(TransformUsageFlags.ManualOverride); + AddComponent(entity, new LocalTransform2D + { + Scale = 1 + }); + AddComponent(entity, new LocalToWorld + { + Value = float4x4.Scale(1) + }); + + var parentGO = authoring.transform.parent; + if (parentGO != null) + { + AddComponent(entity, new Parent + { + Value = GetEntity(parentGO, TransformUsageFlags.None) + }); + } + } + } + } + #endregion + + #region LocalTransform2D + // By including LocalTransform2D in the LocalToWorld write group, entities + // with LocalTransform2D are not processed by the standard transform system. + [WriteGroup(typeof(LocalToWorld))] + public struct LocalTransform2D : IComponentData + { + public float2 Position; + public float Scale; + public float Rotation; + + public override string ToString() + { + return $"Position={Position.ToString()} Rotation={Rotation.ToString()} Scale={Scale.ToString(CultureInfo.InvariantCulture)}"; + } + + public float4x4 ToMatrix() + { + quaternion rotation = quaternion.RotateZ(math.radians(Rotation)); + return float4x4.TRS(new float3(Position.xy, 0f), rotation, Scale); + } + } + #endregion +} diff --git a/DocCodeSamples.Tests/TransformsCustom.cs.meta b/DocCodeSamples.Tests/TransformsCustom.cs.meta new file mode 100644 index 00000000..af3e635e --- /dev/null +++ b/DocCodeSamples.Tests/TransformsCustom.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0f738fbb8440a624a8f77cb7a0cc524c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Documentation~/baking-overview.md b/Documentation~/baking-overview.md index cf54afde..82c5e6ac 100644 --- a/Documentation~/baking-overview.md +++ b/Documentation~/baking-overview.md @@ -58,7 +58,7 @@ The output of a full baking pass is a set of files on the disk. The Editor or yo When a subscene loads an authoring scene, it also initializes incremental baking. Performing an incremental baking pass on the scene means that you can directly access the results of baking while you edit an authoring scene. -During incremental baking, baking happens in memory instead of doing a run-trip to the disk. When you change the contents of authoring GameObjects, Unity re-bakes only the entities and components affected. Baking only a small subset of the data is much faster, and means ECS data can update in real time. This effectively gives the impression of directly editing ECS data, even though baking is continuously happening. +During incremental baking, baking happens in memory instead of doing a round-trip to the disk. When you change the contents of authoring GameObjects, Unity re-bakes only the entities and components affected. Baking only a small subset of the data is much faster, and means ECS data can update in real time. This effectively gives the impression of directly editing ECS data, even though baking is continuously happening. Incremental baking comes with some additional complexity. While full baking always starts from a blank slate and systematically bakes everything, incremental baking always runs on top of the earlier baking pass and only bakes the entities that depend on the authoring GameObjects that have changed. diff --git a/Documentation~/baking.md b/Documentation~/baking.md index 7904e3e0..2b6fe300 100644 --- a/Documentation~/baking.md +++ b/Documentation~/baking.md @@ -1,7 +1,7 @@ # Baking -Baking is a process that transforms GameObject data in the Unity Editor (authoring data) into to entities written to entity scenes (runtime data). +Baking is a process that transforms GameObject data in the Unity Editor (authoring data) into entities written to entity scenes (runtime data). |**Topic**|**Description**| |---|---| diff --git a/Documentation~/components-cleanup-introducing.md b/Documentation~/components-cleanup-introducing.md index 46535813..1771162b 100644 --- a/Documentation~/components-cleanup-introducing.md +++ b/Documentation~/components-cleanup-introducing.md @@ -26,6 +26,11 @@ bool entityExists = EntityManager.Exists(e); > [!NOTE] > Cleanup components are unmanaged and have all of the same restrictions as [unmanaged components](components-unmanaged.md). +> +> The following limitations also apply: +> - Cleanup components are not included when entities are copied between Worlds. +> - As a consequence, cleanup components added at baking time will not be serialized. +> - Cleanup components on prefab entities will not be included on instantiated instances of that prefab. ## Additional resources -* [Unmanaged components](components-unmanaged.md) \ No newline at end of file +* [Unmanaged components](components-unmanaged.md) diff --git a/Documentation~/components-cleanup-shared.md b/Documentation~/components-cleanup-shared.md index 285d97ac..4ea79842 100644 --- a/Documentation~/components-cleanup-shared.md +++ b/Documentation~/components-cleanup-shared.md @@ -1,6 +1,6 @@ # Cleanup shared components -Cleanup shared components are managed [shared components](components-shared.md) that have the destruction semantics of a [cleanup component](components-cleanup.md). They are useful to tag entities that require the same information for clean up. +Cleanup shared components are [shared components](components-shared.md) that have the destruction semantics of a [cleanup component](components-cleanup.md). They are useful to tag entities that require the same information for clean up. ## Create a cleanup shared component diff --git a/Documentation~/components-nativecontainers.md b/Documentation~/components-nativecontainers.md index 133c9354..846a930f 100644 --- a/Documentation~/components-nativecontainers.md +++ b/Documentation~/components-nativecontainers.md @@ -11,7 +11,7 @@ A `NativeContainer` is safer and consistently meets expectations than an `Unsafe ## Component limitations -If you put a container types in a component, they have the following limitations: +If you put container types in a component, they have the following limitations: |**Functionality**|**Native containers**|**Unsafe containers**| |--|--|--| diff --git a/Documentation~/index.md b/Documentation~/index.md index b76d1aae..f14bf59b 100644 --- a/Documentation~/index.md +++ b/Documentation~/index.md @@ -6,9 +6,14 @@ See the [DOTS Guide and Samples](https://github.com/Unity-Technologies/EntityCom ![](images/entities-splash-image.png) +## Supported Unity Versions + +* 2022.3 (LTS) +* 2023.3 (Latest Beta and beyond) + ## Package installation -To use the Entities package, you must have a 2022.3 version of Unity installed. +To use the Entities package, you must have a supported version of Unity installed. To install the package, open the Package Manager window (**Window > Package Manager**) and perform one of the following options: diff --git a/Documentation~/transforms-custom.md b/Documentation~/transforms-custom.md index 1a8072eb..d5edcee1 100644 --- a/Documentation~/transforms-custom.md +++ b/Documentation~/transforms-custom.md @@ -24,43 +24,8 @@ To create your own custom transform system, you have to substitute the `LocalTra 1. Create a .cs file that defines a substitute for the built-in `LocalTransform` component. You can copy the built-in `LocalTransform.cs` file from the Entities package into your assets folder and then edit the contents. To do this, go to **Packages > Entities > Unity.Transforms** in your project, copy the `LocalTransform.cs` file, and rename it. 1. Change the properties and methods to suit your needs. See the following example of a custom `LocalTransform2D` component: - - ```c# - using System.Globalization; - using Unity.Entities; - using Unity.Mathematics; - using Unity.Properties; - using Unity.Transforms; - - [WriteGroup(typeof(LocalToWorld))] - public struct LocalTransform2D : IComponentData - { - [CreateProperty] - public float2 Position; - - [CreateProperty] - public float Scale; - - [CreateProperty] - public float Rotation; - - public override string ToString() - { - return $"Position={Position.ToString()} Rotation={Rotation.ToString()} Scale={Scale.ToString(CultureInfo.InvariantCulture)}"; - } - - /// - /// Gets the float4x4 equivalent of this transform. - /// - /// The float4x4 matrix. - public float4x4 ToMatrix() - { - quaternion rotation = quaternion.RotateZ(math.radians(Rotation)); - var matrixTRS = float4x4.TRS(new float3(Position.xy, 0f), rotation, Scale); - return matrixTRS; - } - } - ``` + +[!code-cs[LocalTransform2DDocsSnippet](../DocCodeSamples.Tests/TransformsCustom.cs#LocalTransform2D)] The above example modifies the built-in `LocalTransform` in the following ways: @@ -82,7 +47,7 @@ Each entity that your custom transform system needs to process must fulfill the To meet this criteria, add an authoring component to each entity, and use [transform usage flags](xref:Unity.Entities.TransformUsageFlags) to prevent the entity from receiving any components from the built-in transform system: -[!code-cs[Transform2DAuthoringDocsSnippet](../../../Projects/EntitiesSamples/Assets/Custom%20Transform%20System/Authoring/Transform2DAuthoring.cs#Transform2DAuthoringDocsSnippet)] +[!code-cs[Transform2DAuthoringDocsSnippet](../DocCodeSamples.Tests/TransformsCustom.cs#Transform2DAuthoring)] The above example adds the custom `LocalTransform2D` component and the built-in `LocalToWorld` component to the authoring component. If applicable, it also adds a `Parent` component that points to the entity's parent entity. diff --git a/Editor Default Resources/uss/ProfilerModules/memory-profiler-left-pane.uss b/Editor Default Resources/uss/ProfilerModules/memory-profiler-left-pane.uss index e8b8d393..23923966 100644 --- a/Editor Default Resources/uss/ProfilerModules/memory-profiler-left-pane.uss +++ b/Editor Default Resources/uss/ProfilerModules/memory-profiler-left-pane.uss @@ -71,6 +71,10 @@ -unity-text-align: middle-left; } +#tree-view-container +{ + flex-grow: 1; +} .memory-profiler-left-pane__tree-view { flex-grow: 1; diff --git a/Editor Default Resources/uss/ProfilerModules/structural-changes-profiler-window.uss b/Editor Default Resources/uss/ProfilerModules/structural-changes-profiler-window.uss index 8a0e8200..b7630d07 100644 --- a/Editor Default Resources/uss/ProfilerModules/structural-changes-profiler-window.uss +++ b/Editor Default Resources/uss/ProfilerModules/structural-changes-profiler-window.uss @@ -72,6 +72,10 @@ -unity-text-align: middle-left; } +#tree-view-container +{ + flex-grow: 1; +} .structural-changes-profiler-window__tree-view { flex-grow: 1; diff --git a/Editor Default Resources/uxml/ProfilerModules/memory-profiler-left-pane.uxml b/Editor Default Resources/uxml/ProfilerModules/memory-profiler-left-pane.uxml index bfefba07..979a98de 100644 --- a/Editor Default Resources/uxml/ProfilerModules/memory-profiler-left-pane.uxml +++ b/Editor Default Resources/uxml/ProfilerModules/memory-profiler-left-pane.uxml @@ -11,6 +11,6 @@ - + diff --git a/Editor Default Resources/uxml/ProfilerModules/structural-changes-profiler-window.uxml b/Editor Default Resources/uxml/ProfilerModules/structural-changes-profiler-window.uxml index a821dbbc..e93079e0 100644 --- a/Editor Default Resources/uxml/ProfilerModules/structural-changes-profiler-window.uxml +++ b/Editor Default Resources/uxml/ProfilerModules/structural-changes-profiler-window.uxml @@ -9,6 +9,6 @@ - + diff --git a/LICENSE.md b/LICENSE.md index 3390ada0..3888abb7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Entities © 2023 Unity Technologies +Entities © 2024 Unity Technologies Licensed under the Unity Companion License for Unity-dependent projects (see https://unity3d.com/legal/licenses/unity_companion_license). diff --git a/Unity.Entities.Editor.Tests/ScriptTemplates.meta b/Unity.Entities.Editor.Tests/ScriptTemplates.meta new file mode 100644 index 00000000..1f9430fb --- /dev/null +++ b/Unity.Entities.Editor.Tests/ScriptTemplates.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a90c825eb28b34ec1886dd34b7d2c32e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity.Entities.Editor.Tests/ScriptTemplates/ScriptTemplatesTests.cs b/Unity.Entities.Editor.Tests/ScriptTemplates/ScriptTemplatesTests.cs new file mode 100644 index 00000000..ddef9350 --- /dev/null +++ b/Unity.Entities.Editor.Tests/ScriptTemplates/ScriptTemplatesTests.cs @@ -0,0 +1,28 @@ +using UnityEditor; +using NUnit.Framework; +using UnityEngine; + +namespace Unity.Entities.Editor.Tests +{ + class ScriptTemplatesTests + { + string[] paths = new string[] + { + $"{ScriptTemplates.ScriptTemplatePath}IComponentDataTemplate.txt", + $"{ScriptTemplates.ScriptTemplatePath}ISystemTemplate.txt", + $"{ScriptTemplates.ScriptTemplatePath}IJobEntityTemplate.txt", + $"{ScriptTemplates.ScriptTemplatePath}BakerTemplate.txt", + }; + + [Test] + public void ScriptTemplatesExist() + { + for (int i = 0; i < paths.Length; i++) + { + var asset = AssetDatabase.LoadAssetAtPath(paths[i]); + + Assert.NotNull(asset); + } + } + } +} diff --git a/Unity.Entities.Editor.Tests/ScriptTemplates/ScriptTemplatesTests.cs.meta b/Unity.Entities.Editor.Tests/ScriptTemplates/ScriptTemplatesTests.cs.meta new file mode 100644 index 00000000..957d82ea --- /dev/null +++ b/Unity.Entities.Editor.Tests/ScriptTemplates/ScriptTemplatesTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0087885995f2040a5ac291979e75354a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity.Entities.Editor/Hierarchy/Model/ChangeTracking/HierarchyEntityChangeTracker.cs b/Unity.Entities.Editor/Hierarchy/Model/ChangeTracking/HierarchyEntityChangeTracker.cs index d5bb878c..786050b1 100644 --- a/Unity.Entities.Editor/Hierarchy/Model/ChangeTracking/HierarchyEntityChangeTracker.cs +++ b/Unity.Entities.Editor/Hierarchy/Model/ChangeTracking/HierarchyEntityChangeTracker.cs @@ -141,7 +141,11 @@ public enum OperationModeType EntityQuery m_ParentQuery; EntityQuery m_SceneTagWithoutParentQuery; +#if ENTITY_STORE_V1 NativeList m_DistinctBuffer; +#else + NativeHashMap m_DistinctBuffer; +#endif /// /// Gets or sets the operation mode used by the change tracker. This determines which components and data drives the hierarchy. @@ -213,7 +217,12 @@ public unsafe HierarchyEntityChangeTracker(World world, Allocator allocator) m_ParentChangeTracker = new ComponentDataDiffer(ecs, ComponentType.ReadOnly()); m_SceneTagWithoutParentChangeTracker = new UnmanagedSharedComponentDataDiffer(ComponentType.ReadOnly()); +#if ENTITY_STORE_V1 m_DistinctBuffer = new NativeList(16, allocator); +#else + m_DistinctBuffer = new NativeHashMap(16, allocator); +#endif + m_EmptyQuery = m_World.EntityManager.CreateEntityQuery(new EntityQueryDesc{All = new ComponentType[] {typeof(UnusedTag)}}); RebuildQueryCache(null); @@ -260,9 +269,7 @@ public void GetChanges(HierarchyEntityChanges changes) { new DistinctJob { -#if !ENTITY_STORE_V1 - EntityCapacity = m_World.EntityManager.HighestEntityIndex() + 1, -#else +#if ENTITY_STORE_V1 EntityCapacity = m_World.EntityManager.EntityCapacity, #endif Changes = changes, @@ -290,37 +297,72 @@ public void GetChanges(HierarchyEntityChanges changes) [BurstCompile] struct DistinctJob : IJob { - public int EntityCapacity; public HierarchyEntityChanges Changes; + +#if ENTITY_STORE_V1 + public int EntityCapacity; public NativeList DistinctBuffer; +#else + public NativeHashMap DistinctBuffer; +#endif public void Execute() { +#if ENTITY_STORE_V1 DistinctBuffer.ResizeUninitialized(EntityCapacity); +#endif if (Changes.CreatedEntities.Length > 0 && Changes.DestroyedEntities.Length > 0) RemoveDuplicate(DistinctBuffer, Changes.CreatedEntities, Changes.DestroyedEntities); if (Changes.AddedParentEntities.Length > 0 && Changes.RemovedParentEntities.Length > 0) +#if ENTITY_STORE_V1 RemoveDuplicate(DistinctBuffer.AsArray(), Changes.AddedParentEntities, Changes.RemovedParentEntities, Changes.AddedParentComponents, Changes.RemovedParentComponents); +#else + RemoveDuplicate(DistinctBuffer, Changes.AddedParentEntities, Changes.RemovedParentEntities, Changes.AddedParentComponents, Changes.RemovedParentComponents); +#endif if (Changes.AddedSceneTagWithoutParentEntities.Length > 0 && Changes.RemovedSceneTagWithoutParentEntities.Length > 0) +#if ENTITY_STORE_V1 RemoveDuplicate(DistinctBuffer.AsArray(), Changes.AddedSceneTagWithoutParentEntities, Changes.RemovedSceneTagWithoutParentEntities, Changes.AddedSceneTagWithoutParentComponents); +#else + RemoveDuplicate(DistinctBuffer, Changes.AddedSceneTagWithoutParentEntities, Changes.RemovedSceneTagWithoutParentEntities, Changes.AddedSceneTagWithoutParentComponents); +#endif } - static unsafe void RemoveDuplicate(NativeList index, NativeList added, NativeList removed) + static unsafe void RemoveDuplicate( +#if ENTITY_STORE_V1 + NativeList index, +#else + NativeHashMap index, +#endif + NativeList added, NativeList removed) { +#if ENTITY_STORE_V1 UnsafeUtility.MemClear(index.GetUnsafePtr(), index.Length * sizeof(int)); +#else + index.Clear(); +#endif var addedLength = added.Length; var removedLength = removed.Length; for (var i = 0; i < addedLength; i++) +#if ENTITY_STORE_V1 index[added[i].Index] = i + 1; +#else + index[added[i]] = i + 1; +#endif for (var i = 0; i < removedLength; i++) { +#if ENTITY_STORE_V1 var addIndex = index[removed[i].Index] - 1; +#else + // TryGetValue returns default is the value is missing. + index.TryGetValue(removed[i], out var addIndex); + addIndex -= 1; +#endif if (addIndex < 0) continue; @@ -336,7 +378,11 @@ static unsafe void RemoveDuplicate(NativeList index, NativeList add added[addIndex] = added[addedLength - 1]; removed[i] = removed[removedLength - 1]; +#if ENTITY_STORE_V1 index[added[addIndex].Index] = addIndex + 1; +#else + index[added[addIndex]] = addIndex + 1; +#endif addedLength--; removedLength--; @@ -347,19 +393,39 @@ static unsafe void RemoveDuplicate(NativeList index, NativeList add removed.ResizeUninitialized(removedLength); } - unsafe void RemoveDuplicate(NativeArray index, NativeList added, NativeList removed, NativeList data) where TData : unmanaged + unsafe void RemoveDuplicate( +#if ENTITY_STORE_V1 + NativeArray index, +#else + NativeHashMap index, +#endif + NativeList added, NativeList removed, NativeList data) where TData : unmanaged { +#if ENTITY_STORE_V1 UnsafeUtility.MemClear(index.GetUnsafePtr(), index.Length * sizeof(int)); +#else + index.Clear(); +#endif var addedLength = added.Length; var removedLength = removed.Length; for (var i = 0; i < addedLength; i++) +#if ENTITY_STORE_V1 index[added[i].Index] = i + 1; +#else + index[added[i]] = i + 1; +#endif for (var i = 0; i < removedLength; i++) { +#if ENTITY_STORE_V1 var addIndex = index[removed[i].Index] - 1; +#else + // TryGetValue returns default is the value is missing. + index.TryGetValue(removed[i], out var addIndex); + addIndex -= 1; +#endif if (addIndex < 0) continue; @@ -376,7 +442,11 @@ unsafe void RemoveDuplicate(NativeArray index, NativeList ad data[addIndex] = data[addedLength - 1]; removed[i] = removed[removedLength - 1]; +#if ENTITY_STORE_V1 index[added[addIndex].Index] = addIndex + 1; +#else + index[added[addIndex]] = addIndex + 1; +#endif addedLength--; removedLength--; @@ -387,19 +457,39 @@ unsafe void RemoveDuplicate(NativeArray index, NativeList ad removed.ResizeUninitialized(removedLength); } - unsafe void RemoveDuplicate(NativeArray index, NativeList addedEntities, NativeList removedEntities, NativeList addedData, NativeList removedData) where TData : unmanaged + unsafe void RemoveDuplicate( +#if ENTITY_STORE_V1 + NativeArray index, +#else + NativeHashMap index, +#endif + NativeList addedEntities, NativeList removedEntities, NativeList addedData, NativeList removedData) where TData : unmanaged { +#if ENTITY_STORE_V1 UnsafeUtility.MemClear(index.GetUnsafePtr(), index.Length * sizeof(int)); +#else + index.Clear(); +#endif var addedLength = addedEntities.Length; var removedLength = removedEntities.Length; for (var i = 0; i < addedLength; i++) +#if ENTITY_STORE_V1 index[addedEntities[i].Index] = i + 1; +#else + index[addedEntities[i]] = i + 1; +#endif for (var i = 0; i < removedLength; i++) { +#if ENTITY_STORE_V1 var addIndex = index[removedEntities[i].Index] - 1; +#else + // TryGetValue returns default is the value is missing. + index.TryGetValue(removedEntities[i], out var addIndex); + addIndex -= 1; +#endif if (addIndex < 0) continue; @@ -424,7 +514,11 @@ unsafe void RemoveDuplicate(NativeArray index, NativeList ad removedEntities[i] = removedEntities[removedLength - 1]; removedData[i] = removedData[removedLength - 1]; +#if ENTITY_STORE_V1 index[addedEntities[addIndex].Index] = addIndex + 1; +#else + index[addedEntities[addIndex]] = addIndex + 1; +#endif addedLength--; removedLength--; diff --git a/Unity.Entities.Editor/Hierarchy/Model/HierarchyNodeStore+Immutable.cs b/Unity.Entities.Editor/Hierarchy/Model/HierarchyNodeStore+Immutable.cs index 42713564..43ac3171 100644 --- a/Unity.Entities.Editor/Hierarchy/Model/HierarchyNodeStore+Immutable.cs +++ b/Unity.Entities.Editor/Hierarchy/Model/HierarchyNodeStore+Immutable.cs @@ -66,7 +66,11 @@ struct Data /// /// The packed index per entity which maps to the packed sets and . /// +#if ENTITY_STORE_V1 [NativeDisableUnsafePtrRestriction] internal UnsafeList* m_IndexByEntity; +#else + [NativeDisableUnsafePtrRestriction] internal UnsafeHashMap* m_IndexByEntity; +#endif /// /// The packed index per non-entity handle. @@ -130,7 +134,12 @@ public Immutable(Allocator allocator) m_Data->ChangeVersion = 0; m_HandleNodes = UnsafeList.Create(16, allocator); m_EntityNodes = UnsafeList.Create(16, allocator); +#if ENTITY_STORE_V1 m_IndexByEntity = UnsafeList.Create(16, allocator); +#else + m_IndexByEntity = AllocatorManager.Allocate>(allocator); + *m_IndexByEntity = new UnsafeHashMap(16, allocator); +#endif m_IndexByHandle = new UnsafeParallelHashMap(16, allocator); Clear(); } @@ -139,7 +148,12 @@ public void Dispose() { UnsafeList.Destroy(m_HandleNodes); UnsafeList.Destroy(m_EntityNodes); +#if ENTITY_STORE_V1 UnsafeList.Destroy(m_IndexByEntity); +#else + m_IndexByEntity->Dispose(); + AllocatorManager.Free(m_Allocator, m_IndexByEntity); +#endif m_IndexByHandle.Dispose(); Memory.Unmanaged.Free(m_Data, m_Allocator); m_Data = null; @@ -154,10 +168,16 @@ public void Clear() m_HandleNodes->Clear(); m_EntityNodes->Clear(); m_IndexByEntity->Clear(); - m_IndexByHandle.Clear(); +#if ENTITY_STORE_V1 // Setup the list to always include a virtual root node. m_IndexByEntity->Add(0); +#else + // Setup the list to always include a virtual root node. + m_IndexByEntity->Add(0, 0); +#endif + + m_IndexByHandle.Clear(); m_HandleNodes->Add(new HierarchyImmutableNodeData { @@ -226,10 +246,15 @@ public int IndexOf(HierarchyNodeHandle handle) { case NodeKind.Entity: { +#if ENTITY_STORE_V1 if (handle.Index < 0 || handle.Index >= m_IndexByEntity->Length) return -1; - return m_IndexByEntity->ElementAt(handle.Index); +#else + if (!m_IndexByEntity->TryGetValue(handle.Index, out var value)) + value = -1; + return value; +#endif } default: @@ -247,7 +272,11 @@ internal void SetPackedIndex(HierarchyNodeHandle handle, int index) switch (handle.Kind) { case NodeKind.Entity: +#if ENTITY_STORE_V1 m_IndexByEntity->ElementAt(handle.Index) = index; +#else + (*m_IndexByEntity)[handle.Index] = index; +#endif break; default: m_IndexByHandle[handle] = index; @@ -260,7 +289,11 @@ internal int GetPackedIndex(HierarchyNodeHandle handle) switch (handle.Kind) { case NodeKind.Entity: +#if ENTITY_STORE_V1 return m_IndexByEntity->ElementAt(handle.Index); +#else + return (*m_IndexByEntity)[handle.Index]; +#endif default: if (!m_IndexByHandle.TryGetValue(handle, out var index)) index = -1; @@ -433,9 +466,7 @@ public bool MoveNext() var job = new ExportImmutableHierarchyNodesBatchJob { ExceptionThrown = &exceptionThrown, -#if !ENTITY_STORE_V1 - EntityCapacity = m_World != null ? m_World.EntityManager.HighestEntityIndex() + 1 : 0, -#else +#if ENTITY_STORE_V1 EntityCapacity = m_World != null ? m_World.EntityManager.EntityCapacity : 0, #endif Nodes = m_Hierarchy.m_Nodes, @@ -522,7 +553,10 @@ public ExportImmutableEnumerator CreateBuildImmutableEnumerator(World world, Exp unsafe struct ExportImmutableHierarchyNodesBatchJob : IJob { [NativeDisableUnsafePtrRestriction] public int* ExceptionThrown; + +#if ENTITY_STORE_V1 public int EntityCapacity; +#endif [ReadOnly] public HierarchyNodeMap Nodes; [ReadOnly] public UnsafeParallelMultiHashMap Children; @@ -574,8 +608,10 @@ public void Execute() WriteNodes.m_HandleNodes->Resize(handleCount, NativeArrayOptions.ClearMemory); WriteNodes.m_HandleNodes->Length = handleCount; +#if ENTITY_STORE_V1 // Allocate a sparse lookup from 'entity' to the baked out index. WriteNodes.m_IndexByEntity->Resize(EntityCapacity, NativeArrayOptions.ClearMemory); +#endif // Start at the root and depth first traverse. PushNode(HierarchyNodeHandle.Root, -1); @@ -627,8 +663,10 @@ public void Execute() void PushNode(HierarchyNodeHandle handle, int parentIndex) { +#if ENTITY_STORE_V1 // Broad phase check to see if the node has changed since the last pack. // This optimization lets us re-use the information from a previous depth first traversal by referring to the last packed buffer (see 'ReadNodes') + if (handle.Kind != NodeKind.Root && Nodes[handle].ChangeVersion <= ReadChangeVersion) { // The read buffer contains the data we are interested, we can perform a copy and remap. @@ -678,6 +716,7 @@ void PushNode(HierarchyNodeHandle handle, int parentIndex) m_PackingIndex += nextSiblingOffset; return; } +#endif var childrenBufferStartIndex = State.ChildrenBuffer.Length; var childCount = 0; @@ -766,7 +805,11 @@ public void Execute() for (var i = 0; i < entityCount; i++) { var entity = WriteNodes.m_EntityNodes->ElementAt(i); +#if ENTITY_STORE_V1 WriteNodes.m_IndexByEntity->ElementAt(entity.Index) = packingIndex++; +#else + (*WriteNodes.m_IndexByEntity)[entity.Index] = packingIndex++; +#endif } State.PackingIndex = packingIndex; diff --git a/Unity.Entities.Editor/Hierarchy/Utility/EntityMapDense.cs b/Unity.Entities.Editor/Hierarchy/Utility/EntityMapDense.cs index ab6de636..4a052818 100644 --- a/Unity.Entities.Editor/Hierarchy/Utility/EntityMapDense.cs +++ b/Unity.Entities.Editor/Hierarchy/Utility/EntityMapDense.cs @@ -11,13 +11,13 @@ namespace Unity.Entities.Editor /// /// /// This structure uses a sparse array mapping to an internal dense array. This uses a fixed size overhead to save on per-entity storage costs. - /// + /// /// This structure is best used if: /// - the size of is larger than ~8 bytes /// - the data must exist on FEW entity in a world /// /// otherwise; consider using - /// + /// /// This data structure has a fixed memory overhead of 8 bytes per entity and will expand as data is added. /// /// The data type to store per entity. @@ -42,7 +42,7 @@ unsafe struct EntityMapDense : IEntityMap where T : unmanaged /// Returns the number of entries in the storage. /// public int Count => m_EntityMapDenseData->Count; - + /// /// Returns the total number of unique entries, not including shared instances. /// @@ -95,7 +95,7 @@ public T this[Entity entity] /// The shared default value to set. public void SetSharedDefaultValue(T value) => m_EntityMapDenseData->SetSharedDefaultValue(value); - + /// /// Gets the shared default value. /// @@ -104,7 +104,7 @@ public T GetSharedDefaultValue() internal void GetDefaultEntities(Entity* entities) => m_EntityMapDenseData->GetDefaultEntities(entities); - + /// /// Clears the storage for re-use. /// @@ -132,7 +132,7 @@ public bool Exists(Entity entity) /// The entity to remove data for. public void Remove(Entity entity) => m_EntityMapDenseData->Remove(entity); - + /// /// Registers an entity to the dense set and assigns it the default value. This method performs no validation for free list checking. Use with caution. /// @@ -142,7 +142,7 @@ public void SetValueDefaultUnchecked(Entity entity) public Enumerator GetEnumerator() => new Enumerator(m_EntityMapDenseData->GetEnumerator()); - + public NonDefaultEntityEnumerator GetNonDefaultEntityEnumerator() => new NonDefaultEntityEnumerator(m_EntityMapDenseData->GetNonDefaultEntityEnumerator()); @@ -165,13 +165,13 @@ public bool MoveNext() public void Reset() => m_Enumerator.Reset(); - public EntityWithValue Current + public EntityWithValue Current => m_Enumerator.Current; - object IEnumerator.Current + object IEnumerator.Current => Current; } - + public struct NonDefaultEntityEnumerator : IEnumerator> { UnsafeEntityMapDense.NonDefaultEntityEnumerator m_Enumerator; @@ -191,29 +191,33 @@ public bool MoveNext() public void Reset() => m_Enumerator.Reset(); - public EntityWithValue Current + public EntityWithValue Current => m_Enumerator.Current; - object IEnumerator.Current + object IEnumerator.Current => Current; } } - + /// /// The internal storage for the . /// unsafe struct UnsafeEntityMapDense : IDisposable where T : unmanaged { +#if ENTITY_STORE_V1 /// /// Sparse indexing in to the dense data set. /// UnsafeEntityMapSparse m_IndexByEntity; - +#else + UnsafeHashMap m_IndexByEntity; +#endif + /// /// A set of free indices in the dense data set. /// UnsafeList m_FreeIndex; - + /// /// The densely packed data array. /// @@ -252,7 +256,7 @@ public T this[Entity entity] /// The allocator type. public UnsafeEntityMapDense(int initialCapacity, Allocator allocator) { - m_IndexByEntity = new UnsafeEntityMapSparse(initialCapacity, allocator); + m_IndexByEntity = new(initialCapacity, allocator); m_FreeIndex = new UnsafeList(initialCapacity, allocator); m_DataByIndex = new UnsafeList(initialCapacity, allocator) {default}; } @@ -296,14 +300,18 @@ public T GetSharedDefaultValue() internal void GetDefaultEntities(Entity* entities) { var index = 0; - + foreach (var entityValuePair in m_IndexByEntity) { if (entityValuePair.Value == 0) +#if ENTITY_STORE_V1 entities[index++] = entityValuePair.Entity; +#else + entities[index++] = entityValuePair.Key; +#endif } } - + /// /// Clears the storage for re-use. /// @@ -320,9 +328,11 @@ public void Clear() /// The capacity to set. public void Resize(int capacity) { +#if ENTITY_STORE_V1 m_IndexByEntity.Resize(capacity); +#endif } - + /// /// Returns true if the given entity exists in the sparse data set. /// @@ -330,7 +340,11 @@ public void Resize(int capacity) /// public bool Exists(Entity entity) { +#if ENTITY_STORE_V1 return m_IndexByEntity.Exists(entity); +#else + return m_IndexByEntity.ContainsKey(entity); +#endif } /// @@ -344,7 +358,7 @@ public void Remove(Entity entity) if (m_IndexByEntity[entity] != 0) m_FreeIndex.Add(m_IndexByEntity[entity]); - + m_IndexByEntity.Remove(entity); } @@ -370,7 +384,7 @@ public void SetValue(Entity entity, T value) Resize(entity.Index + 1); } - if (m_IndexByEntity.Exists(entity)) // This entity already exists in the sparse set. + if (Exists(entity)) // This entity already exists in the sparse set. { if (m_IndexByEntity[entity] == 0) // This entity is currently pointing to the shared 0 index. { @@ -458,23 +472,34 @@ void SetValueForDenseIndex(int index, Entity entity, T value) public Enumerator GetEnumerator() => new Enumerator(m_IndexByEntity.GetEnumerator(), m_DataByIndex); - + public NonDefaultEntityEnumerator GetNonDefaultEntityEnumerator() => new NonDefaultEntityEnumerator(m_IndexByEntity.GetEnumerator(), m_DataByIndex); - + /// /// An enumerator which will iterate all key-value pairs in the map. /// public struct Enumerator : IEnumerator> { - UnsafeEntityMapSparse.Enumerator m_Enumerator; UnsafeList m_Data; +#if ENTITY_STORE_V1 + UnsafeEntityMapSparse.Enumerator m_Enumerator; + public Enumerator(UnsafeEntityMapSparse.Enumerator enumerator, UnsafeList data) { m_Enumerator = enumerator; m_Data = data; } +#else + UnsafeHashMap.Enumerator m_Enumerator; + + public Enumerator(UnsafeHashMap.Enumerator enumerator, UnsafeList data) + { + m_Enumerator = enumerator; + m_Data = data; + } +#endif public void Dispose() { @@ -498,7 +523,11 @@ public EntityWithValue Current return new EntityWithValue { +#if ENTITY_STORE_V1 Entity = entityWithIndex.Entity, +#else + Entity = entityWithIndex.Key, +#endif Value = m_Data[entityWithIndex.Value] }; } @@ -506,20 +535,31 @@ public EntityWithValue Current object IEnumerator.Current => Current; } - + /// /// An enumerator which will iterate all non-default key-value pairs in the map. /// public struct NonDefaultEntityEnumerator : IEnumerator> { - UnsafeEntityMapSparse.Enumerator m_Enumerator; UnsafeList m_DataByIndex; +#if ENTITY_STORE_V1 + UnsafeEntityMapSparse.Enumerator m_Enumerator; + public NonDefaultEntityEnumerator(UnsafeEntityMapSparse.Enumerator enumerator, UnsafeList dataByIndex) { m_Enumerator = enumerator; m_DataByIndex = dataByIndex; } +#else + UnsafeHashMap.Enumerator m_Enumerator; + + public NonDefaultEntityEnumerator(UnsafeHashMap.Enumerator enumerator, UnsafeList dataByIndex) + { + m_Enumerator = enumerator; + m_DataByIndex = dataByIndex; + } +#endif public void Dispose() { @@ -533,9 +573,9 @@ public bool MoveNext() { return false; } - } + } while (m_Enumerator.Current.Value == 0); - + return true; } @@ -552,7 +592,11 @@ public EntityWithValue Current return new EntityWithValue { +#if ENTITY_STORE_V1 Entity = entityWithIndex.Entity, +#else + Entity = entityWithIndex.Key, +#endif Value = m_DataByIndex[entityWithIndex.Value] }; } @@ -561,4 +605,4 @@ public EntityWithValue Current object IEnumerator.Current => Current; } } -} \ No newline at end of file +} diff --git a/Unity.Entities.Editor/ProfilerModules/MemoryProfilerModule+View.cs b/Unity.Entities.Editor/ProfilerModules/MemoryProfilerModule+View.cs index 73679bb6..13f4ba7f 100644 --- a/Unity.Entities.Editor/ProfilerModules/MemoryProfilerModule+View.cs +++ b/Unity.Entities.Editor/ProfilerModules/MemoryProfilerModule+View.cs @@ -167,7 +167,11 @@ void CreateViewLeftPane(VisualElement root) leftHeader.Q