Matching scene view with Camera View?

Is there a simple way to make my scene view match my Main camera view?
if not that would be super useful when working on scenes where your camera doesn’t move.

3 Likes

You can align your scene view camera to your game camera: Select your game camera object in the hierarchy, and use GameObject > Align View To Selected from the Unity Editor Menu.
However that only takes care of alignment, your scene view might still look different due to Projection Size, clipping planes, etc.
I’m not 100% sure if you can fix this via an Editor Script, but the last answer on this thread looks promising: https://answers.unity.com/questions/17608/how-to-get-access-to-the-editor-camera.html?page=2&pageSize=5&sort=votes

If I understand it correctly, this approach would allow you to access the camera object that is rendering your scene view, so you could copy all your game camera parameters 1:1 in a script, then your scene view should look exactly the same.

13 Likes

I found a few quick methods to help out with this question as it was something that I was recently looking for myself. The methods follow below (Mac & PC-friendly options). I hope that they help anyone looking for this same info…

1. Key Command Method - While selecting your camera within the Hierarchy press the following keys:
a. Mac = Command + Shift + F
b. PC = Control + Shift + F

2. Main Navigation Option - While having your main camera selected navigate to the applications main menu:
GameObject > Align With View

36 Likes

perfect! thank you very much! I wasn’t aware of this command and when I, for myself, stumbled across @OP’s problem, your input was very helpful.

3 Likes
using UnityEngine;
using UnityEditor;

[ExecuteInEditMode]
public class AlignCam : MonoBehaviour
{
    public Camera gameCam;
    public bool updateView = false;
    private void LateUpdate()
    {
        if (updateView)
        {
            SceneView sceneCam = SceneView.lastActiveSceneView;
            gameCam.transform.position = sceneCam.camera.transform.position;
            gameCam.transform.rotation = sceneCam.camera.transform.rotation;
        }
    }
}
4 Likes

Expanding on @FaffyWaffles 's (great name btw) solution, here is what I ended up creating:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(Camera))]
public class CameraAligner : Editor {
    private Camera camera;

    private void OnEnable() {
        camera = (Camera)target;
    }

    public override void OnInspectorGUI() {
        if (GUILayout.Button("Align with editor view")) {
            SceneView sceneCam = SceneView.lastActiveSceneView;
            camera.transform.position = sceneCam.camera.transform.position;
            camera.transform.rotation = sceneCam.camera.transform.rotation;
        }
        base.OnInspectorGUI();
    }
}

This way I can choose a view with the editor and then align the selected camera.

2 Likes

Great ! Thanks a lot :heart:

Niceeeee!!

Thank you! This is such a concise answer, it helped :slight_smile: