PlayModeScenarioManager
Manages the lifecycle of Play Mode Scenarios, which define custom behaviors for entering and exiting Play mode, such as launching multiple Player instances.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Class
- Namespace: Unity.PlayMode.Editor
- Assembly: UnityEditor
public static class PlayModeScenarioManager
Remarks
Use the PlayModeScenarioManager to assign, start, and stop the active scenario, and to query its state.
This API extends, rather than replaces, methods like . It's designed for advanced cases that require custom setup and teardown logic or the management of multiple Player instances during Play mode.
EditorApplication.EnterPlaymode[!NOTE] Avoid manually changing the play state via or when a custom scenario is active. Doing so has the following consequences: " Before a scenario runs: Manually starting Play mode causes the manager to set the active scenario to the default one. " While a scenario is running: Manually starting or altering the play state is unsupported and can cause errors.
EditorApplication.EnterPlaymode()EditorApplication.isPlayingThese restrictions don't apply when the default scenario is active. In that case, the behavior is identical to the standard Unity Play mode.
For safer operation, always use and to control Play mode when using custom scenarios.
PlayModeScenarioManager.Start()PlayModeScenarioManager.Stop()Static Properties
Property | Description |
|---|---|
| ActiveScenario | Returns or sets the active play mode scenario. |
| State | Returns the current state of the active play mode scenario. |