Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

EntityManager.AddComponent

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool AddComponent(Entity entity, ComponentType componentType);

Parameters

Parameter Description
entity The Entity.
componentType The type of component to add.

Returns

bool If the component was successfully added to the entity.

Description

Adds a component to an entity.

Can add any kind of component except chunk components. For chunk components, use EntityManager.AddChunkComponentData.

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 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.


Declaration

public bool AddComponent(SystemHandle system, ComponentType componentType);

Parameters

Parameter Description
system The system handle.
componentType The type of component to add.

Returns

bool If the component was successfully added to the entity.

Description

Adds a component to an entity associated with a system.

Can add any kind of component except chunk components. For chunk components, use EntityManager.AddChunkComponentData.

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 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.


Declaration

public bool AddComponent(Entity entity);

Parameters

Parameter Description
entity The Entity.

Returns

bool If the component was successfully added to the entity.

Description

Adds a component to an entity.

Can add any kind of component except chunk components. For chunk components, use EntityManager.AddChunkComponentData.

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 method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before addting 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.


Declaration

public bool AddComponent(SystemHandle system);

Parameters

Parameter Description
system The system handle.

Returns

bool If the component was successfully added to the entity.

Description

Adds a component to an entity associated with a system.

Can add any kind of component except chunk components. For chunk components, use EntityManager.AddChunkComponentData.

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 method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before addting 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.


Declaration

public void AddComponent(EntityQuery entityQuery, ComponentType componentType);

Parameters

Parameter Description
entityQuery The EntityQuery defining the entities to modify.
componentType The type of component to add.

Description

Adds a component to a set of entities defined by a EntityQuery.

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 method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before addting 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.


Declaration

public void AddComponent(EntityQuery entityQuery, ref ComponentTypeSet componentTypeSet);

Parameters

Parameter Description
entityQuery The EntityQuery defining the entities to modify.
componentTypeSet The type of components to add.

Description

Adds components to a set of entities defined by a EntityQuery.

You can use this method to add a component to an Entity.

The added components have the default values for the type.

Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before addting 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.


Declaration

public void AddComponent(EntityQuery entityQuery);

Parameters

Parameter Description
entityQuery The EntityQuery defining the entities to modify.

Description

Adds a component to a set of entities defined by a EntityQuery.

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 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.


Declaration

public void AddComponent(NativeArray<Entity> entities, ComponentType componentType);

Parameters

Parameter Description
entities An array of Entity objects.
componentType The type of component to add.

Description

Adds a component to a set of entities.

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 method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before creating the chunk. 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.


Declaration

public void AddComponent(NativeArray<Entity> entities, ref ComponentTypeSet componentTypeSet);

Parameters

Parameter Description
entities The collection of entities to modify.
componentTypeSet The type of components to add.

Description

Adds components to a specified collection of entities.

You can use this method to add a component to an Entity.

The added components have the default values for the type.

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.


Declaration

public void AddComponent(NativeArray<Entity> entities);

Parameters

Parameter Description
entities An array of Entity objects.

Description

Adds a component to a set of entities.

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 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.


Declaration

public void AddComponent(SystemHandle system, ref ComponentTypeSet componentTypeSet);

Parameters

Parameter Description
system The system handle.
componentTypeSet The types of components to add.

Description

Adds a set of component to an entity associated with a system.

You can use this method to add a component to an Entity.

Adding components changes the 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 the Entity object refers to an entity that has been destroyed, this function throws an InvalidOperationException exception.

Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before setting 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.


Declaration

public void AddComponent(Entity entity, ref ComponentTypeSet componentTypeSet);

Parameters

Parameter Description
entity The entity to modify.
componentTypeSet The types of components to add.

Description

Adds a set of component to an entity.

You can use this method to add a component to an Entity.

Adding components changes the 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 the Entity object refers to an entity that has been destroyed, this function throws an InvalidOperationException exception.

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.