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

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;

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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