Method AddComponentData
AddComponentData<T>(EntityManager, Entity, T)
Adds a managed component to an entity and set the value of that component.
Declaration
public static void AddComponentData<T>(this EntityManager manager, Entity entity, T componentData) where T : class, IComponentData, new()Parameters
| Type | Name | Description | 
|---|---|---|
| EntityManager | manager | This entity manager. | 
| Entity | entity | The entity. | 
| T | componentData | The data to set. | 
Type Parameters
| Name | Description | 
|---|---|
| T | The type of component. | 
Remarks
Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.
Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before adding the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | The Entity does not exist. | 
AddComponentData<T>(EntityManager, SystemHandle, T)
Adds a managed component to an entity associated with a system and set the value of that component.
Declaration
public static void AddComponentData<T>(this EntityManager manager, SystemHandle system, T componentData) where T : class, IComponentData, new()Parameters
| Type | Name | Description | 
|---|---|---|
| EntityManager | manager | This entity manager. | 
| SystemHandle | system | The system handle. | 
| T | componentData | The data to set. | 
Type Parameters
| Name | Description | 
|---|---|
| T | The type of component. | 
Remarks
Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.
Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before adding the component. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | The Entity does not exist. |