Method Instantiate
Instantiate(Entity)
Clones an entity.
Declaration
public Entity Instantiate(Entity srcEntity)
Parameters
Type | Name | Description |
---|---|---|
Entity | srcEntity | The entity to clone. |
Returns
Type | Description |
---|---|
Entity | The Entity object for the new entity. |
Remarks
The new entity has the same archetype and component values as the original; however, ICleanupComponentData and Prefab components are removed from the clone.
If the source entity was converted from a prefab and thus has a LinkedEntityGroup component, the entire group is cloned as a new set of entities. Entity references on components that are being cloned to entities inside the set are remapped to the instantiated entities. Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before creating the entity. 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.
Instantiate(Entity, NativeArray<Entity>)
Makes multiple clones of an entity.
Declaration
public void Instantiate(Entity srcEntity, NativeArray<Entity> outputEntities)
Parameters
Type | Name | Description |
---|---|---|
Entity | srcEntity | The entity to clone. |
NativeArray<Entity> | outputEntities | An array to receive the Entity objects of the root entity in each clone. The length of this array determines the number of clones. |
Remarks
The new entity has the same archetype and component values as the original, however cleanup and prefab tag components are removed from the clone.
If the source entity has a LinkedEntityGroup component, the entire group is cloned as a new set of entities. Entity references on components that are being cloned to entities inside the set are remapped to the instantiated entities.
Important: This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before creating the entity. 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.