docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct EntityCommandBuffer

    A thread-safe command buffer that can buffer commands that affect entities and components for later playback.

    Namespace: Unity.Entities
    Assembly: Unity.Entities.dll
    Syntax
    [NativeContainer]
    [BurstCompile]
    public struct EntityCommandBuffer

    Constructors

    Name Description
    EntityCommandBuffer(Allocator, PlaybackPolicy)

    Creates a new command buffer.

    EntityCommandBuffer(AllocatorHandle)

    Creates a new command buffer.

    EntityCommandBuffer(AllocatorHandle, PlaybackPolicy)

    Creates a new command buffer.

    Properties

    Name Description
    IsCreated

    Is true if the EntityCommandBuffer has been initialized correctly.

    IsEmpty

    Returns true if the EntityCommandBuffer has not been initialized or no commands have been recorded.

    MinimumChunkSize

    Allows controlling the size of chunks allocated from the temp job allocator to back the command buffer.

    PLAYBACK_WITH_TRACE

    A static field for logging details during EntityCommandBuffer playback. When set to true, each EntityCommandBuffer will log its commands as they are processed during playback.

    ShouldPlayback

    Controls whether this command buffer should play back.

    Methods

    Name Description
    AddBuffer<T>(Entity)

    Records a command to add a dynamic buffer to an entity.

    AddComponent(NativeArray<Entity>, ComponentType)

    Records a command to add a component to a NativeArray of entities.

    AddComponent(NativeArray<Entity>, in ComponentTypeSet)

    Records a command to add one or more components to a NativeArray of entities.

    AddComponent(Entity, ComponentType)

    Records a command to add a component to an entity.

    AddComponent(Entity, in ComponentTypeSet)

    Records a command to add one or more components to an entity.

    AddComponent(EntityQuery, ComponentType)

    Obsolete. Use AddComponent(EntityQuery, ComponentType, EntityQueryCaptureMode) instead.

    AddComponent(EntityQuery, ComponentType, EntityQueryCaptureMode)

    Records a command to add a component to all entities matching a query.

    AddComponent(EntityQuery, in ComponentTypeSet)

    Obsolete. Use AddComponent(EntityQuery, in ComponentTypeSet, EntityQueryCaptureMode) instead.

    AddComponent(EntityQuery, in ComponentTypeSet, EntityQueryCaptureMode)

    Records a command to add multiple components to all entities matching a query.

    AddComponentForEntityQuery(EntityQuery, ComponentType)

    Obsolete. Use AddComponent(EntityQuery, ComponentType, EntityQueryCaptureMode) instead.

    AddComponentForEntityQuery(EntityQuery, in ComponentTypeSet)

    Obsolete. Use AddComponent(EntityQuery, in ComponentTypeSet, EntityQueryCaptureMode) instead.

    AddComponentForEntityQuery<T>(EntityQuery)

    Obsolete. Use AddComponent<T>(EntityQuery, EntityQueryCaptureMode) instead.

    AddComponentForEntityQuery<T>(EntityQuery, T)

    Obsolete. Use AddComponent<T>(EntityQuery, T) instead.

    AddComponentForLinkedEntityGroup(Entity, EntityQueryMask, ComponentType)

    Records a command that adds a component to an entity's LinkedEntityGroup based on an EntityQueryMask. Entities in the LinkedEntityGroup that don't match the mask will be skipped safely.

    AddComponentForLinkedEntityGroup<T>(Entity, EntityQueryMask, T)

    Records a command that adds a component to an entity's LinkedEntityGroup based on an EntityQueryMask. Entities in the LinkedEntityGroup that don't match the mask will be skipped safely.

    AddComponentObject(EntityQuery, object)

    Records a command to add a hybrid component and set its value for all entities matching a query.

    AddComponentObjectForEntityQuery(EntityQuery, object)

    Obsolete. Use AddComponentObject(EntityQuery, object) instead.

    AddComponent<T>(NativeArray<Entity>)

    Records a command to add component of type T to a NativeArray of entities.

    AddComponent<T>(NativeArray<Entity>, T)

    Records a command to add component of type T to a NativeArray of entities.

    AddComponent<T>(Entity)

    Records a command to add component of type T to an entity.

    AddComponent<T>(Entity, T)

    Records a command to add component of type T to an entity.

    AddComponent<T>(EntityQuery)

    Obsolete. Use AddComponent<T>(EntityQuery, EntityQueryCaptureMode) instead.

    AddComponent<T>(EntityQuery, EntityQueryCaptureMode)

    Records a command to add a component to all entities matching a query.

    AddComponent<T>(EntityQuery, T)

    Records a command to add a component to all entities matching a query. Also sets the value of this new component on all the matching entities.

    AddSharedComponentForEntityQuery<T>(EntityQuery, T)

    Obsolete. Use AddSharedComponentManaged<T>(EntityQuery, T, EntityQueryCaptureMode) instead.

    AddSharedComponentManaged<T>(NativeArray<Entity>, T)

    Records a command to add a possibly-managed shared component value on a NativeArray of entities.

    AddSharedComponentManaged<T>(Entity, T)

    Records a command to add a possibly-managed shared component value on an entity.

    AddSharedComponentManaged<T>(EntityQuery, T)

    Obsolete. Use AddSharedComponentManaged<T>(EntityQuery, T, EntityQueryCaptureMode) instead.

    AddSharedComponentManaged<T>(EntityQuery, T, EntityQueryCaptureMode)

    Records a command to add a possibly-managed shared component to all entities matching a query.

    AddSharedComponent<T>(NativeArray<Entity>, T)

    Records a command to add an unmanaged shared component value on a NativeArray of entities.

    AddSharedComponent<T>(Entity, T)

    Records a command to add an unmanaged shared component value on an entity.

    AddSharedComponent<T>(EntityQuery, T)

    Obsolete. Use AddSharedComponent<T>(EntityQuery, T, EntityQueryCaptureMode) instead.

    AddSharedComponent<T>(EntityQuery, T, EntityQueryCaptureMode)

    Records a command to add a unmanaged shared component to all entities matching a query.

    AppendToBuffer<T>(Entity, T)

    Records a command to append a single element to the end of a dynamic buffer component.

    AsParallelWriter()

    An extension of EntityCommandBuffer that allows concurrent (deterministic) command buffer recording.

    CreateEntity()

    Records a command to create an entity with no components.

    CreateEntity(EntityArchetype)

    Records a command to create an entity with specified archetype.

    DestroyEntitiesForEntityQuery(EntityQuery)

    Obsolete. Use DestroyEntity(EntityQuery, EntityQueryCaptureMode) instead.

    DestroyEntity(NativeArray<Entity>)

    Records a command to destroy a NativeArray of entities.

    DestroyEntity(Entity)

    Records a command to destroy an entity.

    DestroyEntity(EntityQuery)

    Obsolete. Use DestroyEntity(EntityQuery, EntityQueryCaptureMode) instead.

    DestroyEntity(EntityQuery, EntityQueryCaptureMode)

    Records a command to destroy all entities matching a query.

    Dispose()

    Deals with freeing and releasing unmanaged memory allocated by the entity command buffer.

    Instantiate(Entity)

    Records a command to create an entity with specified entity prefab.

    Instantiate(Entity, NativeArray<Entity>)

    Records a command to create a NativeArray of entities with specified entity prefab.

    Playback(EntityManager)

    Play back all recorded operations against an entity manager.

    Playback(ExclusiveEntityTransaction)

    Play back all recorded operations with an exclusive entity transaction. BeginExclusiveEntityTransaction().

    RemoveComponent(NativeArray<Entity>, ComponentType)

    Records a command to remove one or more components from a NativeArray of entities.

    RemoveComponent(NativeArray<Entity>, in ComponentTypeSet)

    Records a command to remove one or more components from a NativeArray of entities.

    RemoveComponent(Entity, ComponentType)

    Records a command to remove a component from an entity.

    RemoveComponent(Entity, in ComponentTypeSet)

    Records a command to remove one or more components from an entity.

    RemoveComponent(EntityQuery, ComponentType)

    Obsolete. Use RemoveComponent(EntityQuery, ComponentType, EntityQueryCaptureMode) instead.

    RemoveComponent(EntityQuery, ComponentType, EntityQueryCaptureMode)

    Records a command to remove a component from all entities matching a query.

    RemoveComponent(EntityQuery, in ComponentTypeSet)

    Obsolete. Use RemoveComponent(EntityQuery, in ComponentTypeSet, EntityQueryCaptureMode) instead.

    RemoveComponent(EntityQuery, in ComponentTypeSet, EntityQueryCaptureMode)

    Records a command to remove multiple components from all entities matching a query.

    RemoveComponentForEntityQuery(EntityQuery, ComponentType)

    Obsolete. Use RemoveComponent(EntityQuery, ComponentType, EntityQueryCaptureMode) instead.

    RemoveComponentForEntityQuery(EntityQuery, in ComponentTypeSet)

    Obsolete. Use RemoveComponent(EntityQuery, in ComponentTypeSet, EntityQueryCaptureMode) instead.

    RemoveComponentForEntityQuery<T>(EntityQuery)

    Obsolete. Use RemoveComponent<T>(EntityQuery) instead.

    RemoveComponent<T>(NativeArray<Entity>)

    Records a command to remove component of type T from a NativeArray of entities.

    RemoveComponent<T>(Entity)

    Records a command to remove component of type T from an entity.

    RemoveComponent<T>(EntityQuery)

    Obsolete. Use RemoveComponent<T>(EntityQuery, EntityQueryCaptureMode) instead.

    RemoveComponent<T>(EntityQuery, EntityQueryCaptureMode)

    Records a command to remove a component from all entities matching a query.

    ReplaceComponentForLinkedEntityGroup<T>(Entity, T)

    Records a command that replaces a component value for an entity's LinkedEntityGroup. Entities in the LinkedEntityGroup that don't have the component will be skipped safely.

    SetBuffer<T>(Entity)

    Records a command to set a dynamic buffer on an entity.

    SetComponentEnabled(Entity, ComponentType, bool)

    Records a command to enable or disable a ComponentType on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.

    SetComponentEnabled<T>(Entity, bool)

    Records a command to enable or disable a ComponentType on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.

    SetComponentForLinkedEntityGroup<T>(Entity, EntityQueryMask, T)

    Records a command that sets a component for an entity's LinkedEntityGroup based on an EntityQueryMask. Entities in the LinkedEntityGroup that don't match the mask will be skipped safely.

    SetComponentObject(EntityQuery, object)

    Records a command to set a hybrid component value for all entities matching a query.

    SetComponentObjectForEntityQuery(EntityQuery, object)

    Obsolete. Use SetComponentObject(EntityQuery, object) instead.

    SetComponent<T>(Entity, T)

    Records a command to set a component value on an entity.

    SetEnabled(Entity, bool)

    Records a command to add or remove the Disabled component. By default EntityQuery does not include entities containing the Disabled component. Enabled entities are processed by systems, disabled entities are not.

    If the entity was converted from a prefab and thus has a LinkedEntityGroup component, the entire group will be enabled or disabled.

    SetName(Entity, in FixedString64Bytes)

    Records a command to set a name of an entity if Debug Names is enabled.

    SetSharedComponentForEntityQueryManaged<T>(EntityQuery, T)

    Obsolete. Use SetSharedComponentManaged<T>(EntityQuery, T, EntityQueryCaptureMode) instead.

    SetSharedComponentForEntityQuery<T>(EntityQuery, T)

    Obsolete. Use SetSharedComponent<T>(EntityQuery, T, EntityQueryCaptureMode) instead.

    SetSharedComponentManaged<T>(NativeArray<Entity>, T)

    Records a command to set a possibly-managed shared component value on a NativeArray of entities.

    SetSharedComponentManaged<T>(Entity, T)

    Records a command to set a possibly-managed shared component value on an entity.

    SetSharedComponentManaged<T>(EntityQuery, T)

    Obsolete. Use SetSharedComponentManaged<T>(EntityQuery, T, EntityQueryCaptureMode) instead.

    SetSharedComponentManaged<T>(EntityQuery, T, EntityQueryCaptureMode)

    Records a command to set a possibly-managed shared component value on all entities matching a query.

    SetSharedComponent<T>(NativeArray<Entity>, T)

    Records a command to set an unmanaged shared component value on a NativeArray of entities.

    SetSharedComponent<T>(Entity, T)

    Records a command to set an unmanaged shared component value on an entity.

    SetSharedComponent<T>(EntityQuery, T)

    Obsolete. Use SetSharedComponent<T>(EntityQuery, T, EntityQueryCaptureMode) instead.

    SetSharedComponent<T>(EntityQuery, T, EntityQueryCaptureMode)

    Records a command to set an unmanaged shared component value on all entities matching a query.

    Extension Methods

    EntityCommandBufferManagedComponentExtensions.AddComponentForEntityQuery<T>(EntityCommandBuffer, EntityQuery, T)
    EntityCommandBufferManagedComponentExtensions.AddComponent<T>(EntityCommandBuffer, Entity)
    EntityCommandBufferManagedComponentExtensions.AddComponent<T>(EntityCommandBuffer, Entity, T)
    EntityCommandBufferManagedComponentExtensions.AddComponent<T>(EntityCommandBuffer, EntityQuery, T)
    EntityCommandBufferManagedComponentExtensions.MoveComponent<T>(EntityCommandBuffer, Entity, Entity)
    EntityCommandBufferManagedComponentExtensions.SetComponentEnabled<T>(EntityCommandBuffer, Entity, bool)
    EntityCommandBufferManagedComponentExtensions.SetComponentForEntityQuery<T>(EntityCommandBuffer, EntityQuery, T)
    EntityCommandBufferManagedComponentExtensions.SetComponent<T>(EntityCommandBuffer, Entity, T)
    EntityCommandBufferManagedComponentExtensions.SetComponent<T>(EntityCommandBuffer, EntityQuery, T)
    In This Article
    Back to top
    Copyright © 2025 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)