文档

Unity Engine

Unity Engine

GetSharedComponent

Gets a shared component from an entity.
阅读时间1 分钟最后更新于 19 天前

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.