Method AddComponent
AddComponent<T>(Int32, Entity, T)
Records a command to add component of type T to an entity.
Declaration
public void AddComponent<T>(int sortKey, Entity e, T component)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
Int32 | sortKey | A unique index for each set of commands added to this EntityCommandBuffer
across all parallel jobs writing commands to this buffer. The |
Entity | e | The entity to have the component added. |
T | component | The value to add on the new component in playback for the entity. |
Type Parameters
Name | Description |
---|---|
T | The type of component to add. |
Remarks
Behavior 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 this entity is still deferred, if T is type Entity, or adding this componentType makes the archetype too large.
Exceptions
Type | Condition |
---|---|
NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |
AddComponent<T>(Int32, NativeArray<Entity>, T)
Records a command to add component of type T to a NativeArray of entities.
Declaration
public void AddComponent<T>(int sortKey, NativeArray<Entity> entities, T component)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
Int32 | sortKey | A unique index for each set of commands added to this EntityCommandBuffer
across all parallel jobs writing commands to this buffer. The |
NativeArray<Entity> | entities | The NativeArray of entities to have the component added. |
T | component | The value to add on the new component in playback for all entities in the NativeArray. |
Type Parameters
Name | Description |
---|---|
T | The type of component to add. |
Remarks
Behavior 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 any entity is still deferred, if T is type Entity, or adding this componentType makes the archetype too large.
Exceptions
Type | Condition |
---|---|
NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |
AddComponent<T>(Int32, Entity)
Records a command to add component of type T to an entity.
Declaration
public void AddComponent<T>(int sortKey, Entity e)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
Int32 | sortKey | A unique index for each set of commands added to this EntityCommandBuffer
across all parallel jobs writing commands to this buffer. The |
Entity | e | The entity to have the component added. |
Type Parameters
Name | Description |
---|---|
T | The type of component to add. |
Remarks
Behavior 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 this entity is still deferred, if T is type Entity, or adding this componentType makes the archetype too large.
Exceptions
Type | Condition |
---|---|
NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |
AddComponent<T>(Int32, NativeArray<Entity>)
Records a command to add component of type T to a NativeArray of entities.
Declaration
public void AddComponent<T>(int sortKey, NativeArray<Entity> entities)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
Int32 | sortKey | A unique index for each set of commands added to this EntityCommandBuffer
across all parallel jobs writing commands to this buffer. The |
NativeArray<Entity> | entities | The NativeArray of entities to have the component added. |
Type Parameters
Name | Description |
---|---|
T | The type of component to add. |
Remarks
Behavior 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 any entity is still deferred, if T is type Entity, or adding this componentType makes the archetype too large.
Exceptions
Type | Condition |
---|---|
NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |
AddComponent(Int32, Entity, ComponentType)
Records a command to add a component to an entity.
Declaration
public void AddComponent(int sortKey, Entity e, ComponentType componentType)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sortKey | A unique index for each set of commands added to this EntityCommandBuffer
across all parallel jobs writing commands to this buffer. The |
Entity | e | The entity to get the additional component. |
ComponentType | componentType | The type of component to add. |
Remarks
Behavior 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 this entity is still deferred, if component type is type Entity, or adding this componentType makes the archetype too large.
Exceptions
Type | Condition |
---|---|
NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |
AddComponent(Int32, NativeArray<Entity>, ComponentType)
Records a command to add a component to a NativeArray of entities.
Declaration
public void AddComponent(int sortKey, NativeArray<Entity> entities, ComponentType componentType)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sortKey | A unique index for each set of commands added to this EntityCommandBuffer
across all parallel jobs writing commands to this buffer. The |
NativeArray<Entity> | entities | The NativeArray of entities to have the component added. |
ComponentType | componentType | The type of component to add. |
Remarks
Behavior 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 any entity is still deferred, if component type is type Entity, or adding this componentType makes the archetype too large.
Exceptions
Type | Condition |
---|---|
NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |
AddComponent(Int32, Entity, ComponentTypes)
Records a command to add one or more components to an entity.
Declaration
public void AddComponent(int sortKey, Entity e, ComponentTypes types)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sortKey | A unique index for each set of commands added to this EntityCommandBuffer
across all parallel jobs writing commands to this buffer. The |
Entity | e | The entity to get additional components. |
ComponentTypes | types | The types of components to add. |
Remarks
Behavior at Playback: It is 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 this entity is still deferred, if any component type is type Entity, or adding a component type makes the archetype too large.
Exceptions
Type | Condition |
---|---|
NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |
AddComponent(Int32, NativeArray<Entity>, ComponentTypes)
Records a command to add one or more components to a NativeArray of entities.
Declaration
public void AddComponent(int sortKey, NativeArray<Entity> entities, ComponentTypes types)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sortKey | A unique index for each set of commands added to this EntityCommandBuffer
across all parallel jobs writing commands to this buffer. The |
NativeArray<Entity> | entities | The NativeArray of entities to have the components added. |
ComponentTypes | types | The types of components to add. |
Remarks
Behavior at Playback: It is 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 entity is still deferred, if any component type is type Entity, or adding a component type makes the archetype too large.
Exceptions
Type | Condition |
---|---|
NullReferenceException | Throws if an Allocator was not passed in when the EntityCommandBuffer was created. |