Method AddComponent
AddComponent<T>(Entity, T)
Records a command to add component of type T to an entity.
Declaration
public void AddComponent<T>(Entity e, T component)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
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. |
InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |
AddComponent<T>(NativeArray<Entity>, T)
Records a command to add component of type T to a NativeArray of entities.
Declaration
public void AddComponent<T>(NativeArray<Entity> entities, T component)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
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. |
InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |
AddComponent<T>(Entity)
Records a command to add component of type T to an entity.
Declaration
public void AddComponent<T>(Entity e)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
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. |
InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |
AddComponent<T>(NativeArray<Entity>)
Records a command to add component of type T to a NativeArray of entities.
Declaration
public void AddComponent<T>(NativeArray<Entity> entities)
where T : struct, IComponentData
Parameters
Type | Name | Description |
---|---|---|
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. |
InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |
AddComponent(Entity, ComponentType)
Records a command to add a component to an entity.
Declaration
public void AddComponent(Entity e, ComponentType componentType)
Parameters
Type | Name | Description |
---|---|---|
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. |
InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |
AddComponent(NativeArray<Entity>, ComponentType)
Records a command to add a component to a NativeArray of entities.
Declaration
public void AddComponent(NativeArray<Entity> entities, ComponentType componentType)
Parameters
Type | Name | Description |
---|---|---|
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. |
InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |
AddComponent(Entity, ComponentTypes)
Records a command to add one or more components to an entity.
Declaration
public void AddComponent(Entity e, ComponentTypes componentTypes)
Parameters
Type | Name | Description |
---|---|---|
Entity | e | The entity to get additional components. |
ComponentTypes | componentTypes | 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. |
InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |
AddComponent(NativeArray<Entity>, ComponentTypes)
Records a command to add one or more components to a NativeArray of entities.
Declaration
public void AddComponent(NativeArray<Entity> entities, ComponentTypes componentTypes)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<Entity> | entities | The NativeArray of entities to have the components added. |
ComponentTypes | componentTypes | 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. |
InvalidOperationException | Throws if this EntityCommandBuffer has already been played back. |