Method AddComponent
AddComponent(Entity, ComponentType)
Adds a component to an entity.
Declaration
public bool AddComponent(Entity entity, ComponentType componentType)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The Entity object. |
ComponentType | componentType | The type of component to add. |
Returns
Type | Description |
---|---|
Boolean |
Remarks
This method can add any kind of component except chunk components and component objects. For chunk components, use AddChunkComponentData<T>(Entity). For component objects, use AddComponentObject(Entity, Object).
Adding a component changes the entity's archetype and results in the entity being moved to a different chunk.
The added component has the default values for the type.
If the Entity object refers to an entity that has been destroyed, this function throws an ArgumentError exception.
If the Entity object refers to an entity that already has the specified ComponentType, the function returns false without performing any modifications.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before adding the component and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
AddComponent<T>(Entity)
Adds a component to an entity.
Declaration
public bool AddComponent<T>(Entity entity)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The Entity object. |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | The type of component to add. |
Remarks
This method can add any kind of component except chunk components and component objects. For chunk components, use AddChunkComponentData<T>(Entity). For component objects, use AddComponentObject(Entity, Object).
Adding a component changes the entity's archetype and results in the entity being moved to a different chunk.
The added component has the default values for the type.
If the Entity object refers to an entity that has been destroyed, this function throws an ArgumentError exception.
If the Entity object refers to an entity that already has the specified ComponentType of type T, the function returns false without performing any modifications.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before adding the component and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
AddComponent(EntityQuery, ComponentType)
Adds a component to a set of entities defined by a EntityQuery.
Declaration
public void AddComponent(EntityQuery entityQuery, ComponentType componentType)
Parameters
Type | Name | Description |
---|---|---|
EntityQuery | entityQuery | The EntityQuery defining the entities to modify. |
ComponentType | componentType | The type of component to add. |
Remarks
Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.
The added components have the default values for the type.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before adding the component and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
AddComponent(EntityQuery, ComponentTypes)
Adds components to a set of entities defined by a EntityQuery.
Declaration
public void AddComponent(EntityQuery entityQuery, ComponentTypes componentTypes)
Parameters
Type | Name | Description |
---|---|---|
EntityQuery | entityQuery | The EntityQuery defining the entities to modify. |
ComponentTypes | componentTypes | The type of components to add. |
Remarks
Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.
The added components have the default values for the type.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before adding the component and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
AddComponent<T>(EntityQuery)
Adds a component to a set of entities defined by a EntityQuery.
Declaration
public void AddComponent<T>(EntityQuery entityQuery)
Parameters
Type | Name | Description |
---|---|---|
EntityQuery | entityQuery | The EntityQuery defining the entities to modify. |
Type Parameters
Name | Description |
---|---|
T | The type of component to add. |
Remarks
Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.
The added components have the default values for the type.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before adding the component and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
AddComponent(NativeArray<Entity>, ComponentType)
Adds a component to a set of entities.
Declaration
public void AddComponent(NativeArray<Entity> entities, ComponentType componentType)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<Entity> | entities | An array of Entity objects. |
ComponentType | componentType | The type of component to add. |
Remarks
Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.
The added components have the default values for the type.
If an Entity object in the entities
array refers to an entity that has been destroyed, this function
throws an ArgumentError exception.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating these chunks and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
AddComponent<T>(NativeArray<Entity>)
Adds a component to a set of entities.
Declaration
public void AddComponent<T>(NativeArray<Entity> entities)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<Entity> | entities | An array of Entity objects. |
Type Parameters
Name | Description |
---|---|
T | The type of component to add. |
Remarks
Adding a component changes an entity's archetype and results in the entity being moved to a different chunk.
The added components have the default values for the type.
If an Entity object in the entities
array refers to an entity that has been destroyed, this function
throws an ArgumentError exception.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating these chunks and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.