SceneGameView
Static coordinator that enables and disables the Scene Game View feature — overlaying the game camera perspective onto the Scene View. Manages the toggle button injection into the Scene View's "View Options" toolbar.
Definition
Namespace: Paragon.Editor.SceneGameView Assembly: Paragon.Editor.dll
[InitializeOnLoad]
public static class SceneGameViewAttributes: [InitializeOnLoad] — initializes via static constructor on editor load.
Remarks
This class serves as the central entry point for the Scene Game View feature. It has two responsibilities:
1. Enable/Disable Coordination
Enable() activates camera synchronization via SceneGameViewCamera.Enable() and focuses the Game View window (so the game receives input). Disable() deactivates synchronization. Both methods are idempotent — repeated calls are no-ops.
2. Toggle Button Injection
On SceneView.lastActiveSceneViewChanged, the class:
Removes any existing
SceneGameViewTogglefrom the previous Scene View's "View Options" toolbarFinds the "View Options"
OverlayToolbarin the new active Scene View via VisualElement queriesAdds (or reuses) a
SceneGameViewToggleand sends it to the back of the toolbar
FocusGameView
When enabling, the Game View window is focused and a synthetic mouse click is sent to its center. This ensures the game receives input focus via EditorApplication.delayCall to avoid timing issues.
Quick Lookup
Enable game camera overlay
SceneGameView.Enable()
Disable game camera overlay
SceneGameView.Disable()
Check if enabled
SceneGameView.IsEnabled
Properties
IsEnabled
bool
public static
Whether the Scene Game View feature is currently active
Fields
gameViewType
Type
private static readonly
Reflected UnityEditor.GameView type
isEnabled
bool
private static
Backing field for IsEnabled
Methods
Enable
Activates the Scene Game View feature. Enables camera synchronization and focuses the Game View window. No-ops if already enabled.
Disable
Deactivates the Scene Game View feature. Disables camera synchronization and restores original Scene View settings. No-ops if already disabled.
Common Pitfalls
Requires a camera in the scene SceneGameViewCamera.Enable() looks for a camera via FindFirstObjectByType<Camera>(). If no camera exists, a warning is logged and sync will not work.
View Options toolbar query is fragile The toggle injection queries the Scene View's VisualElement hierarchy using .parent.parent.parent.Q("View Options"). This nested parent traversal depends on Unity's internal VisualElement structure and may break between versions.
See Also
SceneGameViewCamera — camera synchronization logic
SceneGameViewToggle — UI toggle button
SceneGameView Overview — subsystem overview
Last updated