Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

EntityCommandBuffer.ParallelWriter.AddComponent

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void AddComponent(int sortKey, Entity e, T component);

Parameters

Parameter Description
sortKey A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.
e The entity to have the component added.
component The value to add on the new component in playback for the entity.

Description

Records a command to add component of type T to an entity.

At playback, if the entity already has this type of component, the value will just be set. Will throw an error if this entity is destroyed before playback, if T is type Entity or Prefab, or adding this componentType makes the archetype too large.


Declaration

public void AddComponent(int sortKey, NativeArray<Entity> entities, T component);

Parameters

Parameter Description
sortKey A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.
entities The NativeArray of entities to have the component added.
component The value to add on the new component in playback for all entities in the NativeArray.

Description

Records a command to add component of type T to a NativeArray of entities.

At playback, if any entity already has this type of component, the value will just be set. Will throw an error if any entity is destroyed before playback, if T is type Entity or Prefab, or adding this componentType makes the archetype too large.


Declaration

public void AddComponent(int sortKey, Entity e);

Parameters

Parameter Description
sortKey A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.
e The entity to have the component added.

Description

Records a command to add component of type T to an entity.

At playback, this command will do nothing if the entity already has the component. Will throw an error if this entity is destroyed before playback, if T is type Entity or Prefab, or adding this componentType makes the archetype too large.


Declaration

public void AddComponent(int sortKey, NativeArray<Entity> entities);

Parameters

Parameter Description
sortKey A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.
entities The NativeArray of entities to have the component added.

Description

Records a command to add component of type T to a NativeArray of entities.

At playback, if an entity already has this component, it will be skipped. Will throw an error if any entity is destroyed before playback, if T is type Entity or Prefab, or adding this componentType makes the archetype too large.


Declaration

public void AddComponent(int sortKey, Entity e, ComponentType componentType);

Parameters

Parameter Description
sortKey A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.
e The entity to get the additional component.
componentType The type of component to add.

Description

Records a command to add a component to an entity.

At playback, this command will do nothing if the entity already has the component. Will throw an error if this entity is destroyed before playback, if component type is type Entity or Prefab, or adding this componentType makes the archetype too large.


Declaration

public void AddComponent(int sortKey, NativeArray<Entity> entities, ComponentType componentType);

Parameters

Parameter Description
sortKey A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.
entities The NativeArray of entities to have the component added.
componentType The type of component to add.

Description

Records a command to add a component to a NativeArray of entities.

At playback, if an entity already has this component, it will be skipped. Will throw an error if any entity is destroyed before playback, if component type is type Entity or Prefab, or adding this componentType makes the archetype too large.


Declaration

public void AddComponent(int sortKey, Entity e, ref ComponentTypeSet typeSet);

Parameters

Parameter Description
sortKey A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.
e The entity to get additional components.
typeSet The types of components to add.

Description

Records a command to add one or more components to an entity.

At playback, it's not an error to include a component type that the entity already has. Will throw an error if this entity is destroyed before playback, if any component type is type Entity or Prefab, or adding a component type makes the archetype too large.


Declaration

public void AddComponent(int sortKey, NativeArray<Entity> entities, ref ComponentTypeSet typeSet);

Parameters

Parameter Description
sortKey A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.
entities The NativeArray of entities to have the components added.
typeSet The types of components to add.

Description

Records a command to add one or more components to a NativeArray of entities.

At playback, it's not an error to include a component type that any of the entities already have. Will throw an error if any entity is destroyed before playback, if any component type is type Entity or Prefab, or adding a component type makes the archetype too large.