Documentation

Unity Engine


Unity Engine


GetSharedComponent

Gets a shared component from an entity.
Read time 1 minuteLast updated 3 days ago

Definition

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

GetSharedComponent<T>(Entity)

Gets a shared component from an entity.
public T GetSharedComponent<T>(Entity entity) where T : unmanaged, ISharedComponentData

Parameters

entity

The entity.

Returns

Type

Description

TA copy of the shared component.

GetSharedComponent<T>(int)

Gets a shared component by index.
public T GetSharedComponent<T>(int sharedComponentIndex) where T : unmanaged, ISharedComponentData

Parameters

sharedComponentIndex

The index of the shared component in the internal shared component list.

Returns

Type

Description

TA copy of the shared component.

Remarks

The ECS framework maintains an internal list of unique shared components. You can get the components in this list, along with their indices using EntityManager.GetAllUniqueSharedComponents. An index in the list is valid and points to the same shared component index as long as the shared component order version from EntityManager.GetSharedComponentOrderVersion remains the same.