World
Encapsulates a set of entities, component data, and systems.
阅读时间3 分钟最后更新于 14 天前
Definition
- Type: Class
- Namespace: Unity.Entities
- Assembly: UnityEngine.EntitiesModule
- Implements: IDisposable
public class World : IDisposable
Remarks
Multiple Worlds may exist concurrently in the same application, but they are isolated from each other; an EntityQuery will only match entities in the World that created the query, a World's EntityManager can only process entities from the same World, etc.
Constructors
Constructor | Description |
|---|---|
| World(System.String,Unity.Entities.WorldFlags) | Construct a new World instance |
| World(System.String,Unity.Entities.WorldFlags,Unity.Collections.AllocatorManager.AllocatorHandle) | Construct a new World instance |
Properties
Property | Description |
|---|---|
| CurrentGroupAllocators | Retrieve current double rewindable allocator for this World. |
| QuitUpdate | Set this property to true to abort a world update after the next system update. |
| Systems | List of all managed systems in this World |
| TimeSingleton | Singleton instance of the WorldTime component. This data is generally accessed through Time. |
| Unmanaged | Gives access to the unmanaged data of an instance of the World. This is useful when your code needs to run with Burst. |
| UpdateAllocatorEnableBlockFree | Property to get and set enable block free flag, a flag indicating whether the allocator should enable individual block to be freed. |
Static Properties
Property | Description |
|---|---|
| All | List of all Worlds that currently exist in the application |
| DefaultGameObjectInjectionWorld | The World that code running outside a system reaches for, at the top of the currently active World stack. Null until Unity creates the first World. |
Methods
Method | Description |
|---|---|
| AddSystemManaged | Adds an existing system instance to this World |
| CreateSystem | Create and return a handle to an instance of a system of type |
| CreateSystemManaged | Create and return an instance of a system of type |
| DestroyAllSystemsAndLogException | Destroy all system instances in the World. Any errors encountered during individual system destruction will be logged to the console. |
| DestroySystem | Destroys one of the World's existing system instances. |
| DestroySystemManaged | Destroys one of the World's existing system instances. |
| Dispose | Dispose of a World instance |
| GetExistingSystem | Return a handle to an existing instance of a system of type |
| GetExistingSystemManaged | Return an existing instance of a system of type |
| GetOrCreateSystem | Retrieve the handle for the instance of a system of type |
| GetOrCreateSystemManaged | Retrieve the instance of a system of type |
| GetOrCreateSystemsAndLogException | Creates systems from the list of types which aren't already created in the current world. |
| PopTime | Restore the previous World time, after pushing a temporary time value with World.PushTime |
| PushTime | Push a new temporary time value to the World's current time |
| RestoreGroupAllocator | Pop group allocator out of the stack. |
| SetGroupAllocator | Push group allocator into a stack. |
| SetTime | Assigns a new value to the World's current time. |
| ToString | Returns the name of the World |
| Update | Update the World's default system groups. |
Static Methods
Method | Description |
|---|---|
| DisposeAllWorlds | Destroys every existing World except the one at the bottom of the currently active World stack. |
| PeekWorldStack | Returns the World on top of the currently active World stack, or null if no World has been pushed. |
| PopWorldStack | Removes |
| PushWorldStack | Makes |
Structs
Struct | Description |
|---|---|
| World.ActiveWorldScope | Makes a World the World.DefaultGameObjectInjectionWorld for the lifetime of the scope, and restores the previous one when the scope ends - including when the body throws. |
| World.NoAllocReadOnlyCollection<T> | Read only collection that doesn't generate garbage when used in a foreach. |