Struct EntityManager
The EntityManager manages entities and components in a World.
Namespace: Unity.Entities
Syntax
public struct EntityManager : IEquatable<EntityManager>
Remarks
The EntityManager provides an API to create, read, update, and destroy entities.
A World 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
Name | Description |
---|---|
Debug | An object providing debugging information and operations. |
EntityCapacity | The capacity of the internal entities array. |
ExclusiveEntityTransactionDependency | |
GlobalSystemVersion | A counter that increments after every system update. |
TotalChunkAddressSpaceInBytes | The total reserved address space for all Chunks in all Worlds. |
UniversalQuery | A EntityQuery instance that matches all components. |
Version | The latest entity generational version. |
World | The World of this EntityManager. |
Methods
Name | Description |
---|---|
AddBuffer<T>(Entity) | Adds a dynamic buffer component to an entity. |
AddChunkComponentData<T>(Entity) | Adds a chunk component to the specified entity. Returns true if the chunk component was added, false if the entity already had the chunk component. (The chunk component's data is set either way.) |
AddChunkComponentData<T>(EntityQuery, T) | Adds a component to each of the chunks identified by a EntityQuery and set the component values. |
AddComponent(NativeArray<Entity>, ComponentType) | Adds a component to a set of entities. |
AddComponent(Entity, ComponentType) | Adds a component to an entity. |
AddComponent(EntityQuery, ComponentType) | Adds a component to a set of entities defined by a EntityQuery. |
AddComponent(EntityQuery, ComponentTypes) | Adds components to a set of entities defined by a EntityQuery. |
AddComponent<T>(NativeArray<Entity>) | Adds a component to a set of entities. |
AddComponent<T>(Entity) | Adds a component to an entity. |
AddComponent<T>(EntityQuery) | Adds a component to a set of entities defined by a EntityQuery. |
AddComponentData<T>(Entity, T) | Adds a component to an entity and set the value of that component. Returns true if the component was added, false if the entity already had the component. (The component's data is set either way.) |
AddComponentData<T>(EntityQuery, NativeArray<T>) | Adds a component to a set of entities defines by the EntityQuery and sets the component of each entity in the query to the value in the component array. componentArray.Length must match entityQuery.ToEntityArray().Length. |
AddComponentObject(Entity, Object) | Adds a managed UnityEngine.Component object to an entity. |
AddComponents(Entity, ComponentTypes) | Adds a set of component to an entity. |
AddSharedComponentData<T>(Entity, T) | Adds a shared component to an entity. Returns true if the shared component was added, false if the entity already had the shared component. (The shared component's data is set either way.) |
AddSharedComponentData<T>(EntityQuery, T) | Adds a shared component to a set of entities defined by a EntityQuery. |
BeginExclusiveEntityTransaction() | Begins an exclusive entity transaction, which allows you to make structural changes inside a Job. |
CompleteAllJobs() | Waits for all Jobs to complete. |
CopyAndReplaceEntitiesFrom(EntityManager) | Copies all entities from srcEntityManager and replaces all entities in this EntityManager |
CopyEntities(NativeArray<Entity>, NativeArray<Entity>) | Clones a set of entities, different from Instantiate because it does not remove the prefab tag component. |
CopyEntitiesFrom(EntityManager, NativeArray<Entity>, NativeArray<Entity>) | 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(ComponentType[]) | Creates an archetype from a set of component types. |
CreateEntity() | Creates an entity with no components. |
CreateEntity(ComponentType[]) | Creates an entity having components of the specified types. |
CreateEntity(EntityArchetype) | Creates an entity having the specified archetype. |
CreateEntity(EntityArchetype, NativeArray<Entity>) | Creates a set of entities of the specified archetype. |
CreateEntity(EntityArchetype, Int32) | Creates a set of entities of the specified archetype. |
CreateEntity(EntityArchetype, Int32, Allocator) | Creates a set of entities of the specified archetype. |
CreateEntityQuery(ComponentType[]) | Creates a EntityQuery from an array of component types. |
CreateEntityQuery(EntityQueryDesc[]) | Creates a EntityQuery from an EntityQueryDesc. |
CreateEntityRemapArray(Allocator) | Creates a remapping array with one element for each entity in the World. |
DestroyAndResetAllEntities() | Destroys all entities in the EntityManager and resets the internal entity ID version table. |
DestroyEntity(NativeArray<Entity>) | Destroys all entities in an array. |
DestroyEntity(NativeSlice<Entity>) | Destroys all entities in a slice of an array. |
DestroyEntity(Entity) | Destroys an entity. |
DestroyEntity(EntityQuery) | Destroy all entities having a common set of component types. |
EndExclusiveEntityTransaction() | Ends an exclusive entity transaction. |
Equals(Object) | |
Equals(EntityManager) | |
Exists(Entity) | Reports whether an Entity object is still valid. |
GetAllArchetypes(NativeList<EntityArchetype>) | Gets all the archetypes. |
GetAllChunks(Allocator) | Gets all the chunks managed by this EntityManager. |
GetAllEntities(Allocator) | Gets all the entities managed by this EntityManager. |
GetAllUniqueSharedComponentData<T>(List<T>) | Gets a list of all the unique instances of a shared component type. |
GetAllUniqueSharedComponentData<T>(List<T>, List<Int32>) | Gets a list of all unique shared components of the same type and a corresponding list of indices into the internal shared component list. |
GetAssignableComponentTypes(Type) | Gets a list of the types of components that can be assigned to the specified component. |
GetAssignableComponentTypes(Type, List<Type>) | Gets a list of the types of components that can be assigned to the specified component. |
GetBuffer<T>(Entity) | Gets the dynamic buffer of an entity. |
GetBufferTypeHandle<T>(Boolean) | Gets the dynamic type object required to access a chunk buffer containing elements of type T. |
GetChunk(Entity) | Gets the chunk in which the specified entity is stored. |
GetChunkComponentData<T>(ArchetypeChunk) | Gets the value of a chunk component. |
GetChunkComponentData<T>(Entity) | Gets the value of chunk component for the chunk containing the specified entity. |
GetComponentCount(Entity) | Gets the number of component types associated with an entity. |
GetComponentData<T>(Entity) | Gets the value of a component for an entity. |
GetComponentObject<T>(Entity) | Gets the managed UnityEngine.Component object from an entity. |
GetComponentObject<T>(Entity, ComponentType) | |
GetComponentOrderVersion<T>() | Gets the version number of the specified component type. |
GetComponentTypeHandle<T>(Boolean) | Gets the dynamic type object required to access a chunk component of type T. |
GetComponentTypes(Entity, Allocator) | Gets an entity's component types. |
GetCreatedAndDestroyedEntities(NativeList<Int32>, NativeList<Entity>, NativeList<Entity>) | Detects the created and destroyed entities compared to last time the method was called with the given state. |
GetCreatedAndDestroyedEntitiesAsync(NativeList<Int32>, NativeList<Entity>, NativeList<Entity>) | Detects the created and destroyed entities compared to last time the method was called with the given state. |
GetDynamicComponentTypeHandle(ComponentType) | Gets the dynamic type object required to access a chunk component of dynamic type acquired from reflection. |
GetDynamicSharedComponentTypeHandle(ComponentType) | Gets the dynamic type object required to access a shared component of the given type. |
GetEnabled(Entity) | |
GetEntityQueryMask(EntityQuery) | Gets an EntityQueryMask that can be used to quickly match if an entity belongs to an EntityQuery. There is a maximum limit of 1024 EntityQueryMasks that can be created. EntityQueryMasks cannot be created from EntityQueries with filters. |
GetEntityTypeHandle() | Gets the dynamic type object required to access the Entity component of a chunk. |
GetHashCode() | |
GetSharedComponentCount() | Gets the number of shared components managed by this EntityManager. |
GetSharedComponentData<T>(Int32) | Gets a shared component by index. |
GetSharedComponentData<T>(Entity) | Gets a shared component from an entity. |
GetSharedComponentDataBoxed(Int32, Int32) | |
GetSharedComponentDataIndex<T>(Entity) | |
GetSharedComponentOrderVersion<T>(T) | Gets the version number of the specified shared component. |
GetSharedComponentTypeHandle<T>() | Gets the dynamic type object required to access a shared component of type T. |
HasChunkComponent<T>(Entity) | Checks whether the chunk containing an entity has a specific type of component. |
HasComponent(Entity, ComponentType) | Checks whether an entity has a specific type of component. |
HasComponent<T>(Entity) | Checks whether an entity has a specific type of component. |
Instantiate(NativeArray<Entity>, NativeArray<Entity>) | Clones a set of entities. |
Instantiate(Entity) | Clones an entity. |
Instantiate(Entity, NativeArray<Entity>) | Makes multiple clones of an entity. |
Instantiate(Entity, Int32, Allocator) | Makes multiple clones of an entity. |
IsQueryValid(EntityQuery) | Check if an entity query is still valid |
MoveEntitiesFrom(out NativeArray<Entity>, EntityManager) | Moves all entities managed by the specified EntityManager to the World of this EntityManager and fills an array with their Entity objects. |
MoveEntitiesFrom(out NativeArray<Entity>, EntityManager, NativeArray<EntityRemapUtility.EntityRemapInfo>) | Moves all entities managed by the specified EntityManager to the World of this EntityManager and fills an array with their Entity objects. |
MoveEntitiesFrom(out NativeArray<Entity>, EntityManager, EntityQuery) | Moves a selection of the entities managed by the specified EntityManager to the World of this EntityManager and fills an array with their Entity objects. |
MoveEntitiesFrom(out NativeArray<Entity>, EntityManager, EntityQuery, NativeArray<EntityRemapUtility.EntityRemapInfo>) | Moves a selection of the entities managed by the specified EntityManager to the World of this EntityManager and fills an array with their Entity objects. |
MoveEntitiesFrom(EntityManager) | Moves all entities managed by the specified EntityManager to the world of this EntityManager. |
MoveEntitiesFrom(EntityManager, NativeArray<EntityRemapUtility.EntityRemapInfo>) | Moves all entities managed by the specified EntityManager to the World of this EntityManager. |
MoveEntitiesFrom(EntityManager, EntityQuery) | Moves a selection of the entities managed by the specified EntityManager to the World of this EntityManager and fills an array with their Entity objects. |
MoveEntitiesFrom(EntityManager, EntityQuery, NativeArray<EntityRemapUtility.EntityRemapInfo>) | Moves a selection of the entities managed by the specified EntityManager to the World of this EntityManager. |
MoveEntitiesFromInternalAll(EntityManager, NativeArray<EntityRemapUtility.EntityRemapInfo>) | |
PrepareForDeserialize() | Prepares an empty World to load serialized entities. |
RemoveChunkComponent<T>(Entity) | Removes a chunk component from the specified entity. Returns false if the entity did not have the component. |
RemoveChunkComponentData<T>(EntityQuery) | Removes a component from the chunks identified by a EntityQuery. |
RemoveComponent(NativeArray<Entity>, ComponentType) | Remove a component from a set of entities. |
RemoveComponent(Entity, ComponentType) | Removes a component from an entity. Returns false if the entity did not have the component. |
RemoveComponent(Entity, ComponentTypes) | Removes multiple components from an entity. |
RemoveComponent(EntityQuery, ComponentType) | Removes a component from a set of entities defined by a EntityQuery. |
RemoveComponent(EntityQuery, ComponentTypes) | Removes a set of components from a set of entities defined by a EntityQuery. |
RemoveComponent<T>(NativeArray<Entity>) | Removes a component from a set of entities. |
RemoveComponent<T>(Entity) | Removes a component from an entity. Returns false if the entity did not have the component. |
RemoveComponent<T>(EntityQuery) | Removes a component from a set of entities defined by a EntityQuery. |
SetArchetype(Entity, EntityArchetype) | Adds and removes components of an entity to match the specified EntityArchetype. |
SetChunkComponentData<T>(ArchetypeChunk, T) | Sets the value of a chunk component. |
SetComponentData<T>(Entity, T) | Sets the value of a component of an entity. |
SetEnabled(Entity, Boolean) | Enabled entities are processed by systems, disabled entities are not. Adds or removes the Disabled component. By default EntityQuery does not include entities containing the Disabled component. If the entity was converted from a prefab and thus has a LinkedEntityGroup component, the entire group will enabled or disabled. |
SetSharedComponentData<T>(Entity, T) | Sets the shared component of an entity. |
SetSharedComponentData<T>(EntityQuery, T) | Sets the shared component of all entities in the query. |
SwapComponents(ArchetypeChunk, Int32, ArchetypeChunk, Int32) | Swaps the components of two entities. |
Operators
Name | Description |
---|---|
Equality(EntityManager, EntityManager) | |
Inequality(EntityManager, EntityManager) |