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. |
ComponentType | componentType | The type of component to add. |
Returns
Type | Description |
---|---|
Boolean |
Remarks
Can add any kind of component except chunk components. For chunk components, use AddChunkComponentData<T>(Entity).
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 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.
Exceptions
Type | Condition |
---|---|
ArgumentException | The Entity does not exist. |
AddComponent<T>(Entity)
Adds a component to an entity.
Declaration
[BurstCompatible(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData)})]
public bool AddComponent<T>(Entity entity)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The Entity. |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | The type of component to add. |
Remarks
Can add any kind of component except chunk components. For chunk components, use AddChunkComponentData<T>(Entity).
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 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.
Exceptions
Type | Condition |
---|---|
ArgumentException | The Entity does not exist. |
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
Can add any kind of component.
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
Can add any kinds of components.
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
[BurstCompatible(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData)})]
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
Can add any kind of component except chunk components.
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
Can add any kind of component except chunk components.
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 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.
Exceptions
Type | Condition |
---|---|
ArgumentException | The |
AddComponent<T>(NativeArray<Entity>)
Adds a component to a set of entities.
Declaration
[BurstCompatible(GenericTypeArguments = new Type[]{typeof(BurstCompatibleComponentData)})]
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
Can add any kind of component.
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 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.
Exceptions
Type | Condition |
---|---|
ArgumentException | The |