docs.unity.cn
    Show / Hide Table of Contents

    Method CreateEntity

    CreateEntity(Int32, EntityArchetype)

    Records a command to create an entity with specified archetype.

    Declaration
    public Entity CreateEntity(int sortKey, EntityArchetype archetype)
    Parameters
    Type Name Description
    Int32 sortKey

    A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from Execute(in ArchetypeChunk, Int32, Boolean, in v128).

    EntityArchetype archetype

    The archetype of the new entity.

    Returns
    Type Description
    Entity

    An entity that is deferred and will be fully realized when this EntityCommandBuffer is played back.

    Remarks

    At playback, this command will throw an error if the archetype contains the Prefab tag.

    Exceptions
    Type Condition
    ArgumentException

    Throws if the archetype is null.

    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    CreateEntity(Int32)

    Records a command to create an entity with no components.

    Declaration
    public Entity CreateEntity(int sortKey)
    Parameters
    Type Name Description
    Int32 sortKey

    A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The ChunkIndexInQuery provided by IJobEntity is an appropriate value to use for this parameter. In an IJobChunk pass the 'unfilteredChunkIndex' value from Execute(in ArchetypeChunk, Int32, Boolean, in v128).

    Returns
    Type Description
    Entity

    An entity that is deferred and will be fully realized when this EntityCommandBuffer is played back.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, June 21, 2023