Version: Unity 6.4 Alpha (6000.4)
LanguageEnglish
  • C#

PlayModeScenarioManager

class in Unity.PlayMode.Editor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Manages the lifecycle of Play Mode Scenarios, which define custom behaviors for entering and exiting Play mode, such as launching multiple Player instances.

Use the PlayModeScenarioManager to assign, start, and stop the active scenario, and to query its state.

This API extends, rather than replaces, methods like EditorApplication.EnterPlaymode. It's designed for advanced cases that require custom setup and teardown logic or the management of multiple Player instances during Play mode.

[!NOTE] Avoid manually changing the play state via EditorApplication.EnterPlaymode() or EditorApplication.isPlaying 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.

These 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 PlayModeScenarioManager.Start() and PlayModeScenarioManager.Stop() to control Play mode when using custom scenarios.

Static Properties

Property Description
ActiveScenario Returns or sets the active play mode scenario.
State Returns the current state of the active play mode scenario.

Static Methods

Method Description
Start Starts the play mode using the active play mode scenario.
Stop Stops the play mode scenario.