docs.unity3d.com
    Show / Hide Table of Contents

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

    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 system state 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 function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating these entities 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.

    Instantiate(Entity, Int32, Allocator)

    Makes multiple clones of an entity.

    Declaration
    public NativeArray<Entity> Instantiate(Entity srcEntity, int instanceCount, Allocator allocator)
    Parameters
    Type Name Description
    Entity srcEntity

    The entity to clone.

    Int32 instanceCount

    The number of entities to instantiate with the same components as the source entity.

    Allocator allocator

    How the created native array should be allocated.

    Returns
    Type Description
    NativeArray<Entity>

    A NativeArray of entities.

    Remarks

    The new entity has the same archetype and component values as the original, however system state 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 function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating these entities 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.

    Instantiate(NativeArray<Entity>, NativeArray<Entity>)

    Clones a set of entities.

    Declaration
    public void Instantiate(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 system state and prefab tag 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 function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating the entity 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.

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023