文档

Unity Engine

Unity Engine

GlobalEntityManager

Reads and changes entities without first looking up the World that owns them.
阅读时间2 分钟最后更新于 1 天前

Definition

  • Type: Class
  • Namespace: Unity.Entities
  • Assembly: UnityEngine.EntitiesModule
public static class GlobalEntityManager

Remarks

Every per-entity method comes in two forms:
"
X(entity)
acts in whichever world owns the entity. Use it when the world is incidental, for example when the entity came from another world, or from a reference stored on a component. "
X(world, entity)
acts in the given world and behaves exactly like
world.EntityManager.X(entity)
: an entity from another world is treated as missing. Use it when the entity must be in that world.
Methods that create something take the world it goes into, because there's no entity to take it from. GlobalEntityManager.Instantiate copies an entity from any world into the given world.
Values that are only meaningful in one world, such as a shared component index, come back with that world.

Static Methods

Method

Description

AddComponentAdds a component to an entity.
AddComponentDataAdds a component to an entity and sets its value.
AddSharedComponentAdds a shared component to an entity.
CreateArchetypeCreates an archetype in the given world.
CreateEntityCreates an entity with no components in the given world.
DestroyEntityDestroys an entity.
ExistsChecks whether an entity exists in any world.
GetBufferGets the dynamic buffer of an entity.
GetComponentDataGets the value of a component for an entity.
GetComponentDataRWGets a read/write reference to a component of an entity.
GetNameGets the name of an entity.
GetSharedComponentGets the value of a shared component of an entity.
GetSharedComponentIndexGets the index of a shared component value of an entity, and the world the index belongs to.
GetWorldGets the managed world that owns an entity.
GetWorldUnmanagedGets the world that owns an entity.
HasBufferChecks whether an entity has a dynamic buffer of a specific type.
HasComponentChecks whether an entity has a specific type of component.
InstantiateClones an entity from any world into the given world.
IsComponentEnabledChecks whether an enableable component of an entity is enabled.
RemoveComponentRemoves a component from an entity.
SetComponentDataSets the value of a component of an entity.
SetComponentEnabledEnables or disables an enableable component of an entity.
SetNameSets the name of an entity.
SetSharedComponentSets the value of a shared component of an entity.