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 : EditorToolbarToggle

Inherits: EditorToolbarToggleToggleBaseField<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 false

  • EnteredEditMode → toggle is disabled, value reset to false, feature disabled

  • OnAttachToPanel → initial state set based on EditorApplication.isPlaying

Event Flow

  1. User clicks toggle → ChangeEvent<bool> fires → OnToggle calls SceneGameView.Enable() or Disable()

  2. Panel detached (Scene View closed) → OnDetachFromPanel calls SceneGameView.Disable() for cleanup

Quick Lookup

Goal
How

Toggle ID

"SceneView/SceneGameView"

Display name

"Toggle Game View"

Icon

DrawGUI.Icon.Unity.GameView

Extension Points

Virtual Methods

Method
Purpose

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.

circle-info

Both OnAttachToPanel and OnDetachFromPanel are protected virtual, allowing subclasses to extend the toggle's behavior while maintaining proper lifecycle management.

Constants

Constant
Type
Value
Description

ID

string

"SceneView/SceneGameView"

Toolbar element identifier

NAME

string

"Toggle Game View"

Display name and tooltip

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated