Documentation

Unity Engine


Unity Engine


GetAllUniqueSharedComponents

Gets a list of all the unique instances of an unmanaged shared component type.
Read time 2 minutesLast updated a day ago

Definition

  • Type: Method
  • Namespace: Unity.Entities
  • Assembly: UnityEngine.EntitiesModule

GetAllUniqueSharedComponents<T>(NativeList<T>, AllocatorHandle)

Gets a list of all the unique instances of an unmanaged shared component type.
public void GetAllUniqueSharedComponents<T>(out NativeList<T> sharedComponentValues, AllocatorManager.AllocatorHandle allocator) where T : unmanaged, ISharedComponentData

Parameters

sharedComponentValues

A List\<T\> object to receive the unique instances of the shared component of type T.

The allocator for the native list of sharedComponentValues

Remarks

All entities with the same archetype and the same values for a shared component are stored in the same set of chunks. This function finds the unique shared components existing across chunks and archetype and fills a list with copies of those components. Note that the first element of the output list will always be the default value for
T
, even if no entities or chunks currently use that value.

GetAllUniqueSharedComponents<T>(NativeList<T>, NativeList<int>, AllocatorHandle)

Gets a list of all the unique instances of an unmanaged shared component type and a corresponding list of indices into the internal shared component list.
public void GetAllUniqueSharedComponents<T>(out NativeList<T> sharedComponentValues, out NativeList<int> sharedComponentIndices, AllocatorManager.AllocatorHandle allocator) where T : unmanaged, ISharedComponentData

Parameters

sharedComponentValues

A NativeList\<T\> to receive the unique instances of the shared component of type T.

sharedComponentIndices

A NativeList\<int\> to receive the indices of those shared components in the internal shared component list.

The allocator for the native lists.

Remarks

All entities with the same archetype and the same values for a shared component are stored in the same set of chunks. This function finds the unique shared components existing across chunks and archetypes and fills a list with copies of those components, plus a parallel list of their indices in the internal shared component list. You can use the indices to ask for the same shared components directly by calling EntityManager.GetSharedComponent, passing in the index. An index remains valid until the shared component order version changes. Note that the first element of the output list will always be the default value for
T
, even if no entities or chunks currently use that value.