docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method CreateEntity

    CreateEntity(EntityArchetype)

    Creates an entity having the specified archetype.

    Declaration
    public Entity CreateEntity(EntityArchetype archetype)
    Parameters
    Type Name Description
    EntityArchetype archetype

    The archetype for the new entity.

    Returns
    Type Description
    Entity

    The Entity object that you can use to access the entity.

    Remarks

    The EntityManager creates the entity in the first available chunk with the matching archetype that has enough space.

    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.

    CreateEntity(EntityArchetype, NativeArray<Entity>)

    Creates a set of entities of the specified archetype.

    Declaration
    public void CreateEntity(EntityArchetype archetype, NativeArray<Entity> entities)
    Parameters
    Type Name Description
    EntityArchetype archetype

    The archetype defining the structure for the new entities.

    NativeArray<Entity> entities

    An array to hold the Entity objects needed to access the new entities. The length of the array determines how many entities are created.

    Remarks

    Fills the NativeArray object assigned to the entities parameter with the Entity objects of the created entities. Each entity has the components specified by the EntityArchetype object assigned to the archetype parameter. The EntityManager adds these entities to the World entity list. Use the Entity objects in the array for further processing, such as setting the component values.

    CreateEntity(params ComponentType[])

    Creates an entity having components of the specified types.

    Declaration
    public Entity CreateEntity(params ComponentType[] types)
    Parameters
    Type Name Description
    ComponentType[] types

    The types of components to add to the new entity.

    Returns
    Type Description
    Entity

    The Entity object that you can use to access the entity.

    Remarks

    The EntityManager creates the entity in the first available chunk with the matching archetype that has enough space.

    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.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)