# EntityManager

> The EntityManager manages entities and components in a World.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule
* **Implements:** [IEquatable\<EntityManager>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
[BurstCompile]
public struct EntityManager : IEquatable<EntityManager>
```

## Remarks

The EntityManager provides an API to create, read, update, and destroy entities.

A [EntityManager.World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md) has one EntityManager, which manages all the entities for that World.

Many EntityManager operations result in "structural changes" that change the layout of entities in memory. Before it can perform such operations, the EntityManager must wait for all running Jobs to complete, an event called a "sync point". A sync point both blocks the main thread and prevents the application from taking advantage of all available cores as the running Jobs wind down.

Although you cannot prevent sync points entirely, you should avoid them as much as possible. To this end, the ECS framework provides the EntityCommandBuffer, which allows you to queue structural changes so that they all occur at one time in the frame.

## Properties

| Property                                                                                                                                     | Description                                                                                                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Debug](/engine/7000.0/script-reference/unity/entities/entitymanager/debug.md)                                                               | An object providing debugging information and operations.                                                                                                                                                                                                                                                            |
| [EntityOrderVersion](/engine/7000.0/script-reference/unity/entities/entitymanager/entityorderversion.md)                                     | If this version number increases, it means that a structural change has occurred (Entities created / destroyed or components added / removed)                                                                                                                                                                        |
| [ExclusiveEntityTransactionDependency](/engine/7000.0/script-reference/unity/entities/entitymanager/exclusiveentitytransactiondependency.md) | An optional [JobHandle](/engine/7000.0/script-reference/unity/jobs/jobhandle.md) that corresponds to the job currently using an ExclusiveEntityTransaction. This job is completed if this EntityManager's [EntityManager.World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md) is destroyed. |
| [GlobalSystemVersion](/engine/7000.0/script-reference/unity/entities/entitymanager/globalsystemversion.md)                                   | A counter that increments after every system update.                                                                                                                                                                                                                                                                 |
| [UniversalQuery](/engine/7000.0/script-reference/unity/entities/entitymanager/universalquery.md)                                             | An EntityQuery instance that matches all normal components and                                                                                                                                                                                                                                                       |
| [UniversalQueryWithSystems](/engine/7000.0/script-reference/unity/entities/entitymanager/universalquerywithsystems.md)                       | An EntityQuery instance that matches all normal components and                                                                                                                                                                                                                                                       |
| [World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md)                                                               | The [EntityManager.World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md) of this EntityManager.                                                                                                                                                                                              |
| [WorldUnmanaged](/engine/7000.0/script-reference/unity/entities/entitymanager/worldunmanaged.md)                                             | The [EntityManager.WorldUnmanaged](/engine/7000.0/script-reference/unity/entities/entitymanager/worldunmanaged.md) of this EntityManager.                                                                                                                                                                            |

## Static Properties

| Property                                                                                                                       | Description                                                    |
| ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- |
| [TotalChunkAddressSpaceInBytes](/engine/7000.0/script-reference/unity/entities/entitymanager/totalchunkaddressspaceinbytes.md) | The total reserved address space for all Chunks in all Worlds. |

## Methods

| Method                                                                                                                                     | Description                                                                                                                                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AddBuffer](/engine/7000.0/script-reference/unity/entities/entitymanager/addbuffer.md)                                                     | Adds a dynamic buffer component to an entity.                                                                                                                                                                                                               |
| [AddChunkComponentData](/engine/7000.0/script-reference/unity/entities/entitymanager/addchunkcomponentdata.md)                             | Adds a chunk component to the specified entity.                                                                                                                                                                                                             |
| [AddComponent](/engine/7000.0/script-reference/unity/entities/entitymanager/addcomponent.md)                                               | Adds a component to a set of entities.                                                                                                                                                                                                                      |
| [AddComponentData](/engine/7000.0/script-reference/unity/entities/entitymanager/addcomponentdata.md)                                       | Adds a component to an entity and set the value of that component.                                                                                                                                                                                          |
| [AddSharedComponent](/engine/7000.0/script-reference/unity/entities/entitymanager/addsharedcomponent.md)                                   | Adds a shared component to multiple entities                                                                                                                                                                                                                |
| [AddTransform](/engine/7000.0/script-reference/unity/entities/entitymanager/addtransform.md)                                               | Adds a transform to an entity.                                                                                                                                                                                                                              |
| [BeginExclusiveEntityTransaction](/engine/7000.0/script-reference/unity/entities/entitymanager/beginexclusiveentitytransaction.md)         | Begins an exclusive entity transaction, which allows you to make structural changes inside a Job.                                                                                                                                                           |
| [CanBeginExclusiveEntityTransaction](/engine/7000.0/script-reference/unity/entities/entitymanager/canbeginexclusiveentitytransaction.md)   | Check whether or not a new exclusive entity transaction can begin.                                                                                                                                                                                          |
| [CompleteAllTrackedJobs](/engine/7000.0/script-reference/unity/entities/entitymanager/completealltrackedjobs.md)                           | Waits for all tracked jobs to complete.                                                                                                                                                                                                                     |
| [CompleteDependencyBeforeRO](/engine/7000.0/script-reference/unity/entities/entitymanager/completedependencybeforero.md)                   | Completes the dependency chain required for this component to have read access. So it completes all write dependencies of the component to allow for reading.                                                                                               |
| [CompleteDependencyBeforeRW](/engine/7000.0/script-reference/unity/entities/entitymanager/completedependencybeforerw.md)                   | Completes the dependency chain required for this component to have read and write access. So it completes all write dependencies of the component to allow for reading, and it completes all read dependencies, so we can write to it.                      |
| [CopyEntitiesFrom](/engine/7000.0/script-reference/unity/entities/entitymanager/copyentitiesfrom.md)                                       | Instantiates / Copies all entities from srcEntityManager and copies them into this EntityManager. Entity references on components that are being cloned to entities inside the srcEntities set are remapped to the instantiated entities.                   |
| [CreateArchetype](/engine/7000.0/script-reference/unity/entities/entitymanager/createarchetype.md)                                         | Creates an archetype from a set of component types.                                                                                                                                                                                                         |
| [CreateEntity](/engine/7000.0/script-reference/unity/entities/entitymanager/createentity.md)                                               | Creates an entity with no components.                                                                                                                                                                                                                       |
| [CreateEntityQuery](/engine/7000.0/script-reference/unity/entities/entitymanager/createentityquery.md)                                     | Creates a EntityQuery from an array of component types.                                                                                                                                                                                                     |
| [CreateEntityRemapArray](/engine/7000.0/script-reference/unity/entities/entitymanager/createentityremaparray.md)                           | Creates a remapping array with one element for each entity in the [EntityManager.World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md).                                                                                             |
| [CreateSingleton](/engine/7000.0/script-reference/unity/entities/entitymanager/createsingleton.md)                                         | Creates and supports only a single entity with a given unmanaged component.                                                                                                                                                                                 |
| [CreateSingletonBuffer](/engine/7000.0/script-reference/unity/entities/entitymanager/createsingletonbuffer.md)                             | Creates and supports only a single entity with a given unmanaged component buffer.                                                                                                                                                                          |
| [DestroyEntity](/engine/7000.0/script-reference/unity/entities/entitymanager/destroyentity.md)                                             | Destroys all entities in an array.                                                                                                                                                                                                                          |
| [DetachChildren](/engine/7000.0/script-reference/unity/entities/entitymanager/detachchildren.md)                                           | Break the parent/child links between the target entity and all of its children. Each child entity becomes the root of a new hierarchy.                                                                                                                      |
| [EndExclusiveEntityTransaction](/engine/7000.0/script-reference/unity/entities/entitymanager/endexclusiveentitytransaction.md)             | Ends an active [ExclusiveEntityTransaction](/engine/7000.0/script-reference/unity/entities/exclusiveentitytransaction.md) and returns ownership of the [EntityManager](/engine/7000.0/script-reference/unity/entities/entitymanager.md) to the main thread. |
| [Equals](/engine/7000.0/script-reference/unity/entities/entitymanager/equals.md)                                                           | Reports whether this EntityManager references the same manager as another object.                                                                                                                                                                           |
| [Exists](/engine/7000.0/script-reference/unity/entities/entitymanager/exists.md)                                                           | Reports whether an Entity object is still valid.                                                                                                                                                                                                            |
| [GetAllArchetypes](/engine/7000.0/script-reference/unity/entities/entitymanager/getallarchetypes.md)                                       | Gets all the archetypes.                                                                                                                                                                                                                                    |
| [GetAllChunks](/engine/7000.0/script-reference/unity/entities/entitymanager/getallchunks.md)                                               | Gets all the chunks managed by this EntityManager.                                                                                                                                                                                                          |
| [GetAllChunksAndMetaChunks](/engine/7000.0/script-reference/unity/entities/entitymanager/getallchunksandmetachunks.md)                     | Gets all the chunks managed by this EntityManager, including the meta chunks (containing chunk components).                                                                                                                                                 |
| [GetAllEntities](/engine/7000.0/script-reference/unity/entities/entitymanager/getallentities.md)                                           | Gets all the entities managed by this EntityManager.                                                                                                                                                                                                        |
| [GetAllUniqueSharedComponents](/engine/7000.0/script-reference/unity/entities/entitymanager/getalluniquesharedcomponents.md)               | Gets a list of all the unique instances of an unmanaged shared component type.                                                                                                                                                                              |
| [GetAssignableComponentTypes](/engine/7000.0/script-reference/unity/entities/entitymanager/getassignablecomponenttypes.md)                 | Gets a list of the types of components that can be assigned to the specified component.                                                                                                                                                                     |
| [GetBuffer](/engine/7000.0/script-reference/unity/entities/entitymanager/getbuffer.md)                                                     | Gets the dynamic buffer of an entity.                                                                                                                                                                                                                       |
| [GetBufferTypeHandle](/engine/7000.0/script-reference/unity/entities/entitymanager/getbuffertypehandle.md)                                 | Gets the dynamic type object required to access a chunk buffer containing elements of type T.                                                                                                                                                               |
| [GetChunk](/engine/7000.0/script-reference/unity/entities/entitymanager/getchunk.md)                                                       | Gets the chunk in which the specified entity is stored.                                                                                                                                                                                                     |
| [GetChunkComponentData](/engine/7000.0/script-reference/unity/entities/entitymanager/getchunkcomponentdata.md)                             | Gets the value of a chunk component.                                                                                                                                                                                                                        |
| [GetComponentCount](/engine/7000.0/script-reference/unity/entities/entitymanager/getcomponentcount.md)                                     | Gets the number of component types associated with an entity.                                                                                                                                                                                               |
| [GetComponentData](/engine/7000.0/script-reference/unity/entities/entitymanager/getcomponentdata.md)                                       | Gets the value of a component for an entity.                                                                                                                                                                                                                |
| [GetComponentDataRW](/engine/7000.0/script-reference/unity/entities/entitymanager/getcomponentdatarw.md)                                   | Gets the value of a component for an entity.                                                                                                                                                                                                                |
| [GetComponentOrderVersion](/engine/7000.0/script-reference/unity/entities/entitymanager/getcomponentorderversion.md)                       | Gets the version number of the specified component type.                                                                                                                                                                                                    |
| [GetComponentTypeHandle](/engine/7000.0/script-reference/unity/entities/entitymanager/getcomponenttypehandle.md)                           | Gets the dynamic type object required to access a chunk component of type T.                                                                                                                                                                                |
| [GetComponentTypes](/engine/7000.0/script-reference/unity/entities/entitymanager/getcomponenttypes.md)                                     | Gets an entity's component types.                                                                                                                                                                                                                           |
| [GetDynamicComponentTypeHandle](/engine/7000.0/script-reference/unity/entities/entitymanager/getdynamiccomponenttypehandle.md)             | Gets the dynamic type object required to access a chunk component of dynamic type acquired from reflection.                                                                                                                                                 |
| [GetDynamicSharedComponentTypeHandle](/engine/7000.0/script-reference/unity/entities/entitymanager/getdynamicsharedcomponenttypehandle.md) | Gets the dynamic type object required to access a shared component of the given type.                                                                                                                                                                       |
| [GetEntityTypeHandle](/engine/7000.0/script-reference/unity/entities/entitymanager/getentitytypehandle.md)                                 | Gets the dynamic type object required to access the [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) component of a chunk.                                                                                                                |
| [GetHashCode](/engine/7000.0/script-reference/unity/entities/entitymanager/gethashcode.md)                                                 | Computes a hash code for this object                                                                                                                                                                                                                        |
| [GetName](/engine/7000.0/script-reference/unity/entities/entitymanager/getname.md)                                                         | Gets the name assigned to an entity.                                                                                                                                                                                                                        |
| [GetSharedComponent](/engine/7000.0/script-reference/unity/entities/entitymanager/getsharedcomponent.md)                                   | Gets a shared component by index.                                                                                                                                                                                                                           |
| [GetSharedComponentCount](/engine/7000.0/script-reference/unity/entities/entitymanager/getsharedcomponentcount.md)                         | Gets the number of shared components managed by this EntityManager.                                                                                                                                                                                         |
| [GetSharedComponentDataBoxed](/engine/7000.0/script-reference/unity/entities/entitymanager/getsharedcomponentdataboxed.md)                 | Retrieves a shared component value as a managed boxed object.                                                                                                                                                                                               |
| [GetSharedComponentIndex](/engine/7000.0/script-reference/unity/entities/entitymanager/getsharedcomponentindex.md)                         | Retrieves the index of the unmanaged shared component for an entity.                                                                                                                                                                                        |
| [GetSharedComponentOrderVersion](/engine/7000.0/script-reference/unity/entities/entitymanager/getsharedcomponentorderversion.md)           | Gets the version number of the specified shared component.                                                                                                                                                                                                  |
| [GetSharedComponentTypeHandle](/engine/7000.0/script-reference/unity/entities/entitymanager/getsharedcomponenttypehandle.md)               | Gets the dynamic type object required to access a shared component of type T.                                                                                                                                                                               |
| [GetStorageInfo](/engine/7000.0/script-reference/unity/entities/entitymanager/getstorageinfo.md)                                           | Gets a struct containing information about the archetype in which an entity is stored.                                                                                                                                                                      |
| [GetTransformRef](/engine/7000.0/script-reference/unity/entities/entitymanager/gettransformref.md)                                         | Gets a reference to the transform of an entity.                                                                                                                                                                                                             |
| [GetTransformTypeHandle](/engine/7000.0/script-reference/unity/entities/entitymanager/gettransformtypehandle.md)                           | Gets a type handle for accessing entity transforms in a chunk.                                                                                                                                                                                              |
| [HasBuffer](/engine/7000.0/script-reference/unity/entities/entitymanager/hasbuffer.md)                                                     | Checks whether an entity has a dynamic buffer of a specific IBufferElementData type.                                                                                                                                                                        |
| [HasChunkComponent](/engine/7000.0/script-reference/unity/entities/entitymanager/haschunkcomponent.md)                                     | Checks whether the chunk containing an entity has a specific type of component.                                                                                                                                                                             |
| [HasComponent](/engine/7000.0/script-reference/unity/entities/entitymanager/hascomponent.md)                                               | Checks whether an entity has a specific type of component.                                                                                                                                                                                                  |
| [Instantiate](/engine/7000.0/script-reference/unity/entities/entitymanager/instantiate.md)                                                 | Clones an entity.                                                                                                                                                                                                                                           |
| [IsComponentEnabled](/engine/7000.0/script-reference/unity/entities/entitymanager/iscomponentenabled.md)                                   | Checks whether a given [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) is enabled on the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md).                                                     |
| [IsEnabled](/engine/7000.0/script-reference/unity/entities/entitymanager/isenabled.md)                                                     | Check whether an entire entity has the [Disabled](/engine/7000.0/script-reference/unity/entities/disabled.md) tag component.                                                                                                                                |
| [IsQueryValid](/engine/7000.0/script-reference/unity/entities/entitymanager/isqueryvalid.md)                                               | Check if an entity query is still valid                                                                                                                                                                                                                     |
| [MoveEntitiesFrom](/engine/7000.0/script-reference/unity/entities/entitymanager/moveentitiesfrom.md)                                       | Moves all entities managed by the specified EntityManager to the [EntityManager.World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md) of this EntityManager and fills an array with their Entity objects.                           |
| [PrepareForDeserialize](/engine/7000.0/script-reference/unity/entities/entitymanager/preparefordeserialize.md)                             | Prepares an empty [EntityManager.World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md) to load serialized entities.                                                                                                                 |
| [RemoveChunkComponent](/engine/7000.0/script-reference/unity/entities/entitymanager/removechunkcomponent.md)                               | Removes a chunk component from the specified entity.                                                                                                                                                                                                        |
| [RemoveChunkComponentData](/engine/7000.0/script-reference/unity/entities/entitymanager/removechunkcomponentdata.md)                       | Removes a chunk component from the chunks identified by an EntityQuery.                                                                                                                                                                                     |
| [RemoveComponent](/engine/7000.0/script-reference/unity/entities/entitymanager/removecomponent.md)                                         | Remove a component from a set of entities.                                                                                                                                                                                                                  |
| [SetArchetype](/engine/7000.0/script-reference/unity/entities/entitymanager/setarchetype.md)                                               | Adds and removes components of a NativeArray of Entities to match the specified EntityArchetype.                                                                                                                                                            |
| [SetChunkComponentData](/engine/7000.0/script-reference/unity/entities/entitymanager/setchunkcomponentdata.md)                             | Sets the value of a chunk component.                                                                                                                                                                                                                        |
| [SetComponentData](/engine/7000.0/script-reference/unity/entities/entitymanager/setcomponentdata.md)                                       | Sets the value of a component of an entity.                                                                                                                                                                                                                 |
| [SetComponentEnabled](/engine/7000.0/script-reference/unity/entities/entitymanager/setcomponentenabled.md)                                 | Enable or disable [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) on the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md).                                                                     |
| [SetEnabled](/engine/7000.0/script-reference/unity/entities/entitymanager/setenabled.md)                                                   | Adds or removes the [Disabled](/engine/7000.0/script-reference/unity/entities/disabled.md) component to an [Entity](/engine/7000.0/script-reference/unity/entities/entity.md).                                                                              |
| [SetName](/engine/7000.0/script-reference/unity/entities/entitymanager/setname.md)                                                         | Sets the name of an entity.                                                                                                                                                                                                                                 |
| [SetParent](/engine/7000.0/script-reference/unity/entities/entitymanager/setparent.md)                                                     | Establish a new link between a child and parent entity.                                                                                                                                                                                                     |
| [SetSharedComponent](/engine/7000.0/script-reference/unity/entities/entitymanager/setsharedcomponent.md)                                   | Sets the shared component value on an array of entities                                                                                                                                                                                                     |
| [SwapComponents](/engine/7000.0/script-reference/unity/entities/entitymanager/swapcomponents.md)                                           | Swaps the components of two entities.                                                                                                                                                                                                                       |

## Operators

| Operator                                                                                     | Description                                      |
| -------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| [operator ==](/engine/7000.0/script-reference/unity/entities/entitymanager/op-equality.md)   | Compare two EntityManager objects for equality   |
| [operator !=](/engine/7000.0/script-reference/unity/entities/entitymanager/op-inequality.md) | Compare two EntityManager objects for inequality |

## Structs

| Struct                                                                                                                 | Description                                               |
| ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [EntityManager.EntityManagerDebug](/engine/7000.0/script-reference/unity/entities/entitymanager/entitymanagerdebug.md) | Provides information and utility functions for debugging. |

## Enums

| Enum                                                                                                                         | Description                                                                       |
| ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [EntityManager.GetAllEntitiesOptions](/engine/7000.0/script-reference/unity/entities/entitymanager/getallentitiesoptions.md) | Options include internal entity types such as metaChunkEntity or system entities. |
