SceneGameViewToggle
An EditorToolbarToggle button that appears in the Scene View's "View Options" toolbar. Toggles the Scene Game View feature on and off, and automatically manages Play Mode state transitions.
Definition
Namespace: Paragon.Editor.SceneGameView Assembly: Paragon.Editor.dll
[EditorToolbarElement(ID, typeof(SceneView))]
public class SceneGameViewToggle : EditorToolbarToggleInherits: EditorToolbarToggle → Toggle → BaseField<bool> → VisualElement Attributes: [EditorToolbarElement] — registers as a Scene View toolbar element.
Remarks
This toggle integrates with the Scene View overlay system. It is not placed via [Overlay] but is manually injected into the "View Options" toolbar by SceneGameView.OnActiveSceneViewChanged.
Play Mode Awareness
The toggle is only enabled during Play Mode:
EnteredPlayMode → toggle is enabled, value reset to
falseEnteredEditMode → toggle is disabled, value reset to
false, feature disabledOnAttachToPanel → initial state set based on
EditorApplication.isPlaying
Event Flow
User clicks toggle →
ChangeEvent<bool>fires →OnTogglecallsSceneGameView.Enable()orDisable()Panel detached (Scene View closed) →
OnDetachFromPanelcallsSceneGameView.Disable()for cleanup
Quick Lookup
Toggle ID
"SceneView/SceneGameView"
Display name
"Toggle Game View"
Icon
DrawGUI.Icon.Unity.GameView
Extension Points
Virtual Methods
OnAttachToPanel(AttachToPanelEvent)
Called when the toggle is added to a panel. Subscribes to play mode changes and sets initial state.
OnDetachFromPanel(DetachFromPanelEvent)
Called when the toggle is removed from a panel. Unsubscribes from events and disables the feature.
Both OnAttachToPanel and OnDetachFromPanel are protected virtual, allowing subclasses to extend the toggle's behavior while maintaining proper lifecycle management.
Constants
ID
string
"SceneView/SceneGameView"
Toolbar element identifier
NAME
string
"Toggle Game View"
Display name and tooltip
Common Pitfalls
Toggle is disabled in Edit Mode The toggle calls SetEnabled(false) when not in Play Mode. Users cannot activate the feature without entering Play Mode first.
Feature auto-disables on Play Mode exit When exiting Play Mode (EnteredEditMode), the feature is automatically disabled and the toggle value is reset. This prevents stale camera sync state from persisting.
See Also
SceneGameView — coordinator that injects this toggle into the toolbar
SceneGameViewCamera — camera sync activated by this toggle
SceneGameView Overview — subsystem overview
Last updated