Documentation

Unity Engine

Unity Engine

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

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
world
onto the currently active World stack.

Methods

Method

Description

DisposePops the World this scope pushed, restoring the previously active one.