SceneGraphEditor
Custom OdinEditor for the SceneGraph ScriptableObject. Provides the UI for managing scenes and dependencies in Unity's Project Settings, with circular dependency detection and automatic Build Settings synchronization.
Definition
Namespace: Paragon.Core.SceneManagement.Editor Assembly: Paragon.Editor.dll
[CustomEditor(typeof(SceneGraph))]
internal class SceneGraphEditor : OdinEditorInheritance: OdinEditor → SceneGraphEditor
Remarks
SceneGraphEditor is the primary UI for the Scene Graph system. It is registered as both a [CustomEditor] and a [SettingsProvider] (at Project/Scene Graph), making the graph accessible from Unity's Project Settings window.
Key behaviors:
Scene list rendering — Draws the
scenesproperty with a custom "Add" button that opens aSceneSelectMenupopupCircular dependency detection — On every
OnInspectorGUI()repaint, validates the graph for cycles using DFS. If a cycle is found, displays an error with the dependency chain (e.g.,A → B → C → A)Auto Build Settings sync — Compares the graph's scene list with
EditorBuildSettings.sceneson every repaint. If they differ (and no circular dependency exists), auto-saves and syncsSafety on close — If the editor is closed with an unresolved circular dependency,
EditorBuildSettings.scenesis cleared to prevent broken builds
Odin Integration
An inner AttributeProcessor adds [DoNotDrawAsReference] and [ListDrawerSettings] to the scenes member, configuring:
ShowFoldout = false— No collapsible header for the scenes listHideRemoveButton = true— Remove is handled bySceneNodeDrawer's custom X button
Methods
OnInspectorGUI
Main draw method. Renders the scene list, checks for circular dependencies, and auto-syncs Build Settings.
CreateSceneGraphProvider
Registers the SceneGraph as a Project Settings panel at Project/Scene Graph.
Returns: An AssetSettingsProvider wrapping the SceneGraph singleton.
Common Pitfalls
Circular dependencies clear Build Settings If the editor is closed while a circular dependency exists, EditorBuildSettings.scenes is set to an empty array. Resolve all cycles before closing the Scene Graph settings.
Auto-save on every change The editor calls EditorSceneManager.SaveSceneGraphAsset() whenever Build Settings differ from the graph. This means every scene add/remove/reorder is immediately persisted.
Accessed via Project Settings Open Edit > Project Settings > Scene Graph to access the editor. It's registered via the [SettingsProvider] attribute on CreateSceneGraphProvider().
See Also
SceneNodeDrawer — Draws individual scene nodes within this editor
SceneSelectMenu — Popup used for the "Add Scene" button
EditorSceneManager — Persistence and Build Settings API used by this editor
Last updated