Documentation

Unity Engine


Unity Engine


SetSharedComponent

Records a command to set an unmanaged shared component value on all entities matching a query.
Read time 2 minutesLast updated a day ago

Definition

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

SetSharedComponent<T>(EntityQuery, T, EntityQueryCaptureMode)

Records a command to set an unmanaged shared component value on all entities matching a query.
public void SetSharedComponent<T>(EntityQuery entityQuery, T component, EntityQueryCaptureMode queryCaptureMode) where T : unmanaged, ISharedComponentData

Parameters

entityQuery

The query specifying which entities to add the component value to.

component

T
The component value to add.

queryCaptureMode

Controls when the entities matching
entityQuery
are computed and captured.

Remarks

Fails if any of the entities do not have the type of shared component. [todo: should it be required that the component type is included in the query?]

SetSharedComponent<T>(EntityQuery, T)

Warning
Deprecated. This method now takes an extra parameter to control when the query is evaluated. To preserve the current semantics, use EntityQueryCaptureMode.AtRecord (RemovedAfter Entities 2.0)
public void SetSharedComponent<T>(EntityQuery entityQuery, T component) where T : unmanaged, ISharedComponentData

Parameters

entityQuery

The query specifying the entities to which the component is added.

component

T
The component value to set.

SetSharedComponent<T>(Entity, T)

Records a command to set an unmanaged shared component value on an entity.
public void SetSharedComponent<T>(Entity e, T sharedComponent) where T : unmanaged, ISharedComponentData

Parameters

The entity to set the shared component value of.

sharedComponent

T
The shared component value to set.

Remarks

At playback, this command throws an error if this entity is destroyed before playback, if the entity has the Prefab tag, or if the entity doesn't have the shared component type.

SetSharedComponent<T>(NativeArray<Entity>, T)

Records a command to set an unmanaged shared component value on a NativeArray of entities.
public void SetSharedComponent<T>(NativeArray<Entity> entities, T sharedComponent) where T : unmanaged, ISharedComponentData

Parameters

The NativeArray of entities to set the shared component value of.

sharedComponent

T
The shared component value to set.

Remarks

At playback, this command throws an error if any entity is destroyed before playback, if any entity has the Prefab tag, or if any entity doesn't have the shared component type.