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 SceneGameViewCameraRemarks
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:
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
Start camera sync
SceneGameViewCamera.Enable()
Stop camera sync
SceneGameViewCamera.Disable()
Fields
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
FindFirstObjectByType camera selection Enable() uses Object.FindFirstObjectByType<Camera>() which returns an arbitrary camera. In scenes with multiple cameras, the selected camera may not be the intended main camera. The sync will also re-find a camera if the original is destroyed.
Canvas mode switch side effects Switching a canvas to ScreenSpaceCamera and back to ScreenSpaceOverlay may cause layout recalculations. The canvas is toggled enabled = false → true to force a refresh, which may trigger layout events.
Scene View navigation is locked While enabled, Scene View navigation (panning, orbiting, zooming) is effectively disabled because the camera position is overwritten every frame. Users must disable the feature to navigate the Scene View manually.
See Also
SceneGameView — coordinator that calls Enable/Disable
SceneGameViewToggle — UI toggle
SceneGameView Overview — subsystem overview
Last updated