2
\$\begingroup\$

I'm writing the custom menu using MenuItem and I'm stuck trying to make scene view orthographic when 5 is pressed. What is the object or method I can use to set scene's view to orthographic (I don't mean the main camera, but the main view shown in the window).

This is a C# code of what I was trying to achieve:

[MenuItem("View/SetOrtho _5")]
static void SetOrtho() {
    var scene = ... //assign scene
    scene.setOrtho(true); //set orthographic view to the scene
}
\$\endgroup\$
1
\$\begingroup\$

This documentation is for Unity 2019, so it’s not clear whether this applies to 2018 or older, but it’s worth a shot.

The gist is

 UnityEditor.SceneView.lastActiveSceneView.orthographic = true;
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.