# EntityCommandBuffer

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

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
[BurstCompile]
public struct EntityCommandBuffer : IDisposable
```

## Constructors

| Constructor                                                                                                                                           | Description                   |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
| [EntityCommandBuffer(Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/ctor.md) | Creates a new command buffer. |

## Properties

| Property                                                                                                   | Description                                                                                                                                                                  |
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [IsCreated](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/iscreated.md)               | Is true if the [EntityCommandBuffer](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer.md) has been initialized correctly.                                  |
| [IsEmpty](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/isempty.md)                   | Returns true if the [EntityCommandBuffer](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer.md) has not been initialized or no commands have been recorded. |
| [MinimumChunkSize](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/minimumchunksize.md) | Allows controlling the size of chunks allocated from the temp job allocator to back the command buffer.                                                                      |
| [ShouldPlayback](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/shouldplayback.md)     | Controls whether this command buffer should play back.                                                                                                                       |

## Static Properties

| Property                                                                                                           | Description                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [PLAYBACK\_WITH\_TRACE](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/playback-with-trace.md) | 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. |

## Methods

| Method                                                                                                                                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                              |
| -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AddBuffer](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/addbuffer.md)                                                       | Records a command to add a dynamic buffer to an entity.                                                                                                                                                                                                                                                                                                                                                                                  |
| [AddComponent](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/addcomponent.md)                                                 | Records a command to add a component to a NativeArray of entities.                                                                                                                                                                                                                                                                                                                                                                       |
| [AddComponentForLinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/addcomponentforlinkedentitygroup.md)         | Records a command that adds a component to an entity's [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) based on an [EntityQueryMask](/engine/7000.0/script-reference/unity/entities/entityquerymask.md). Entities in the [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) that don't match the mask will be skipped safely.                             |
| [AddSharedComponent](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/addsharedcomponent.md)                                     | Records a command to add an unmanaged shared component value on a NativeArray of entities.                                                                                                                                                                                                                                                                                                                                               |
| [AppendToBuffer](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/appendtobuffer.md)                                             | Records a command to append a single element to the end of a dynamic buffer component.                                                                                                                                                                                                                                                                                                                                                   |
| [AsParallelWriter](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/asparallelwriter.md)                                         | An extension of EntityCommandBuffer that allows concurrent (deterministic) command buffer recording.                                                                                                                                                                                                                                                                                                                                     |
| [CreateEntity](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/createentity.md)                                                 | Records a command to create an entity with no components.                                                                                                                                                                                                                                                                                                                                                                                |
| [DestroyEntity](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/destroyentity.md)                                               | Records a command to destroy a NativeArray of entities.                                                                                                                                                                                                                                                                                                                                                                                  |
| [Dispose](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/dispose.md)                                                           | Deals with freeing and releasing unmanaged memory allocated by the entity command buffer.                                                                                                                                                                                                                                                                                                                                                |
| [Instantiate](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/instantiate.md)                                                   | Records a command to create an entity with specified entity prefab.                                                                                                                                                                                                                                                                                                                                                                      |
| [Playback](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/playback.md)                                                         | Play back all recorded operations against an entity manager.                                                                                                                                                                                                                                                                                                                                                                             |
| [RemoveComponent](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/removecomponent.md)                                           | Records a command to remove one or more components from a NativeArray of entities.                                                                                                                                                                                                                                                                                                                                                       |
| [ReplaceComponentForLinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/replacecomponentforlinkedentitygroup.md) | Records a command that replaces a component value for an entity's [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md). Entities in the [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) that don't have the component will be skipped safely.                                                                                                               |
| [SetBuffer](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/setbuffer.md)                                                       | Records a command to set a dynamic buffer on an entity.                                                                                                                                                                                                                                                                                                                                                                                  |
| [SetComponent](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/setcomponent.md)                                                 | Records a command to set a component value on an entity.                                                                                                                                                                                                                                                                                                                                                                                 |
| [SetComponentEnabled](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/setcomponentenabled.md)                                   | Records a command to enable or disable a [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) on the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md). 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](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/setcomponentforlinkedentitygroup.md)         | Records a command that sets a component for an entity's [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) based on an [EntityQueryMask](/engine/7000.0/script-reference/unity/entities/entityquerymask.md). Entities in the [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) that don't match the mask will be skipped safely.                            |
| [SetEnabled](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/setenabled.md)                                                     | Records a command to add or remove the [Disabled](/engine/7000.0/script-reference/unity/entities/disabled.md) component. By default EntityQuery does not include entities containing the Disabled component. Enabled entities are processed by systems, disabled entities are not.                                                                                                                                                       |
| [SetName](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/setname.md)                                                           | Records a command to set a name of an entity if Debug Names is enabled.                                                                                                                                                                                                                                                                                                                                                                  |
| [SetSharedComponent](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/setsharedcomponent.md)                                     | Records a command to set an unmanaged shared component value on a NativeArray of entities.                                                                                                                                                                                                                                                                                                                                               |

## Structs

| Struct                                                                                                                     | Description                                                 |
| -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [EntityCommandBuffer.ParallelWriter](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/parallelwriter.md) | Allows concurrent (deterministic) command buffer recording. |
