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.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Struct
- Namespace: Unity.Entities
- Assembly: UnityEngine.EntitiesModule
- Implements: IDisposable
public readonly struct World.ActiveWorldScope : IDisposable
Remarks
Use this wherever the borrow fits a single scope. Where it cannot - a borrow spanning a test's setup and teardown, for example - call World.PushWorldStack and World.PopWorldStack directly instead.
Scopes must end in the reverse of the order they began; World.ActiveWorldScope.Dispose throws otherwise.
Examples
using (new World.ActiveWorldScope(myWorld)){ // World.DefaultGameObjectInjectionWorld is myWorld here.}
Constructors
Constructor | Description |
|---|---|
| ActiveWorldScope(Unity.Entities.World) | Pushes |