Method CopyEntities
CopyEntities(NativeArray<Entity>, NativeArray<Entity>)
Clones a set of entities, different from Instantiate because it does not remove the Prefab tag component.
Declaration
[ExcludeFromCoverage]
[Obsolete("This method is not safe to use in some contexts, and will be removed from the public API in a future Entities release. To create copies of a prefab Entity, use EntityManager.Instantiate().")]
public void CopyEntities(NativeArray<Entity> srcEntities, NativeArray<Entity> outputEntities)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<Entity> | srcEntities | The set of entities to clone |
NativeArray<Entity> | outputEntities | the set of entities that were cloned. outputEntities.Length must match srcEntities.Length |
Remarks
The new entity has the same archetype and component values as the original, however cleanup components are removed from the clone.
Entity references on components that are being cloned to entities inside the set are remapped to the instantiated entities. This method overload ignores the LinkedEntityGroup component, since the group of entities that will be cloned is passed explicitly.
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.