EditorSceneManager
Sealed editor-time extension of SceneManager that adds scene opening/closing, SceneGraph asset persistence, Build Settings synchronization, and play mode scene management.
Definition
Namespace: Paragon.Core.SceneManagement.Editor Assembly: Paragon.Editor.dll
public sealed class EditorSceneManager : SceneManagerInheritance: SceneManager → EditorSceneManager
Remarks
EditorSceneManager bridges the runtime SceneManager with Unity's editor scene APIs. It is initialized via [InitializeOnLoadMethod] and provides:
Scene open/close with dependency chain support —
OpenScene()andCloseScene()can traverseSceneNodedependenciesSceneGraph persistence — The graph is stored at
ProjectSettings/SceneGraph.assetusingInternalEditorUtilityserialization (not a standard Unity asset)Build Settings sync —
ApplySceneGraphToBuildSettings()keepsEditorBuildSettings.scenesin sync with the graphPlay mode management — On entering play mode, the current active scene is saved to
EditorPrefsand restored viaRuntimeInitializeafter the "Main" scene loads
The class fires SceneOpened and SceneClosed events (editor-only) that wrap Unity's internal scene lifecycle callbacks. Scenes not found in the SceneGraph trigger a warning but are still handled gracefully.
Quick Lookup
Open a scene in editor
EditorSceneManager.OpenScene(scene)
Open scene with dependencies
EditorSceneManager.OpenScene(scene, openDependencies: true)
Close a scene
EditorSceneManager.CloseScene(scene)
Check if scene is open
EditorSceneManager.IsSceneOpened(scene)
Get all opened scenes
EditorSceneManager.GetOpenedScenes()
Get all project scenes
EditorSceneManager.GetAllScenesInProject()
Get the SceneGraph
EditorSceneManager.GetSceneGraph()
Save graph to disk
EditorSceneManager.SaveSceneGraphAsset()
Sync Build Settings
EditorSceneManager.ApplySceneGraphToBuildSettings()
Events
SceneOpened
Fired when a scene is opened in the editor. The Scene parameter may be null if the opened scene is not in the SceneGraph.
SceneClosed
Fired when a scene is closed in the editor. The Scene parameter may be null if the closed scene is not in the SceneGraph.
Methods
OpenScene
Opens a scene in the editor, optionally loading its dependency chain first.
scene
Scene
—
Scene to open
openDependencies
bool
false
Load dependency chain scenes first
openSceneMode
OpenSceneMode
SINGLE
SINGLE replaces all; ADDITIVE adds alongside
When openDependencies is true, dependency scenes are opened first in ADDITIVE mode regardless of the initial openSceneMode, then the target scene is opened with the specified mode.
CloseScene
Closes a scene in the editor, optionally closing its dependency chain.
scene
Scene
—
Scene to close
closeDependencies
bool
false
Also close dependency chain scenes
GetOpenedScenes
Returns all SceneGraph scenes currently open in the editor.
Returns: Scenes from the graph that are currently loaded and valid.
IsSceneOpened
Checks if a scene is currently loaded in the editor.
GetAllScenesInProject
Scans the Assets folder for all .scene files, regardless of whether they're in the SceneGraph.
GetSceneGraph
Gets the current SceneGraph, loading or creating it as needed.
Returns: The singleton SceneGraph instance. Creates a new one if none exists.
LoadSceneGraphAsset
Loads the SceneGraph from ProjectSettings/SceneGraph.asset.
SaveSceneGraphAsset
Saves the current SceneGraph to ProjectSettings/SceneGraph.asset.
ApplySceneGraphToBuildSettings
Syncs EditorBuildSettings.scenes to match the SceneGraph scene list.
SaveCurrentModifiedScenesIfUserWantsTo
Prompts the user to save modified scenes. Wraps Unity's built-in dialog.
Returns: true if the user saved or discarded changes; false if cancelled.
Common Pitfalls
SceneGraph is NOT a regular asset The SceneGraph is stored in ProjectSettings/SceneGraph.asset using InternalEditorUtility.SaveToSerializedFileAndForget(). It will not appear in the Project window. Use GetSceneGraph() to access it.
Scenes not in SceneGraph trigger warnings Opening or closing scenes that aren't in the graph logs a warning. This is expected for editor-only scenes but may indicate missing graph entries for runtime scenes.
Play mode start scene is the "Main" scene UpdatePlayModeStartScene() sets playModeStartScene to the scene named "Main" when any scene from the graph is active. If no scene named "Main" exists, play mode uses the current scene.
See Also
SceneGraphEditor — Custom Inspector that uses
EditorSceneManagerfor persistence and syncSceneGraphBuildProcessor — Build processor that injects the graph into builds
Internals/SceneHierarchyWindow — Used to expand scenes in Hierarchy during play mode
Last updated