Method AddComponent
AddComponent<T>(EntityCommandBuffer, Entity, T)
Records a command to add and set a managed component for an entity.
Declaration
public static void AddComponent<T>(this EntityCommandBuffer ecb, Entity e, T component)
where T : class, IComponentData
Parameters
Type | Name | Description |
---|---|---|
EntityCommandBuffer | ecb | |
Entity | e | The entity to set the component value on. |
T | component | The component value to add. |
Type Parameters
Name | Description |
---|---|
T |
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, 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>(EntityCommandBuffer, Entity)
Records a command to add a managed component for an entity.
Declaration
public static void AddComponent<T>(this EntityCommandBuffer ecb, Entity e)
where T : class, IComponentData
Parameters
Type | Name | Description |
---|---|---|
EntityCommandBuffer | ecb | |
Entity | e | The entity to set the component value on. |
Type Parameters
Name | Description |
---|---|
T |
Remarks
Behavior at Playback: Will throw an error if this entity is destroyed before playback, if this entity is still deferred, 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. |