SceneGameViewCamera

Static utility that synchronizes the game camera's transform and settings to the Scene View camera every frame. Stores and restores the original Scene View camera settings when toggling.

Definition

Namespace: Paragon.Editor.SceneGameView Assembly: Paragon.Editor.dll

public static class SceneGameViewCamera

Remarks

This class performs the actual camera synchronization for the Scene Game View feature. It hooks into SceneView.beforeSceneGui to update the Scene View camera before each repaint.

Synchronization Details

Each frame, UpdateSync copies from the game camera to the Scene View:

Property
Source
Target

Position

gameCamera.transform.position

sceneView.pivot (offset by cameraDistance)

Rotation

gameCamera.transform.rotation

sceneView.rotation

Projection

gameCamera.orthographic

sceneView.orthographic

Ortho size

gameCamera.orthographicSize

sceneView.size (only if orthographic)

Near clip

gameCamera.nearClipPlane

sceneView.cameraSettings.nearClip

Far clip

gameCamera.farClipPlane

sceneView.cameraSettings.farClip

FOV

gameCamera.fieldOfView

sceneView.cameraSettings.fieldOfView

Additionally, dynamicClip, accelerationEnabled, and easingEnabled are disabled, and speed is set to 0 to prevent Scene View navigation from interfering.

Canvas Handling

If a Canvas is found in the scene, it is switched to RenderMode.ScreenSpaceCamera with the Scene View camera as its worldCamera. The planeDistance is set to nearClip + 0.1f. On disable, the canvas is restored to ScreenSpaceOverlay mode with a forced refresh.

Settings Preservation

All original Scene View settings (pivot, rotation, size, orthographic, and the full CameraSettings struct) are captured on Enable() and restored on Disable() via deep copy.

Quick Lookup

Goal
How

Start camera sync

SceneGameViewCamera.Enable()

Stop camera sync

SceneGameViewCamera.Disable()

Fields

Field
Type
Access
Description

gameCamera

Camera

private static

The game camera being synced from

canvas

Canvas

private static

The scene canvas (if found) for UI overlay

sceneViewPivot

Vector3

private static

Stored original Scene View pivot

sceneViewRotation

Quaternion

private static

Stored original Scene View rotation

sceneViewSize

float

private static

Stored original Scene View size

sceneViewOrthographic

bool

private static

Stored original orthographic state

sceneCameraSettings

SceneView.CameraSettings

private static

Stored original camera settings (deep copy)

Methods

Enable

Finds the game camera and canvas, stores original Scene View settings, and subscribes to SceneView.beforeSceneGui for per-frame sync.

Disable

Restores original Scene View settings, resets canvas to ScreenSpaceOverlay, clears references, and unsubscribes from SceneView.beforeSceneGui.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated