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 SceneGameView

Attributes: [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:

  1. Removes any existing SceneGameViewToggle from the previous Scene View's "View Options" toolbar

  2. Finds the "View Options" OverlayToolbar in the new active Scene View via VisualElement queries

  3. Adds (or reuses) a SceneGameViewToggle and 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

Goal
How

Enable game camera overlay

SceneGameView.Enable()

Disable game camera overlay

SceneGameView.Disable()

Check if enabled

SceneGameView.IsEnabled

Properties

Property
Type
Access
Description

IsEnabled

bool

public static

Whether the Scene Game View feature is currently active

Fields

Field
Type
Access
Description

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

circle-exclamation
circle-exclamation

See Also

Last updated