Sponsored By

Reset Scene View

Where I explain how I reset the scene view of my Unity scenes to easily fit my 2D projects' requirements.

Amir Barak, Blogger

December 29, 2014

1 Min Read

This is going to be a fairly short post. Nothing overly complicated but, hopefully, useful.

Long before Unity3D had built-in 2D capabilities (not that the current 2D implementation is that beneficial to be honest) it was too easy to accidently move the scene camera and toss things out of alignment. Now, I know that fixing the scene to a particular plane and orthographic view can easily be achieved via the little scene gizmo at the top/left of the editing window, this action also requires mouse movement and at least a few button clicks. I prefer hotkeys for common operations. Not to mention that having things available through code allows greater control overall.

The steps to achieve this are not complicated.

  1. Get the current scene view.

  2. Set scene view to orthographic.

  3. Rotate scene view to correct angle.

  4. Expend scene view to a comfortable size.

I've added that last one in because Unity has a tendency of zooming in too close to things when reset; the comfortable size value itself can be experimented with in order to achieve your own needs. So without further ado; let's see the code.

[MenuItem(MenuName.UtilityItems + "Reset Scene View" + Hotkey.CtrlShift.L)]
public static void Perform()
{
  var current = SceneView.currentDrawingSceneView;
  current.orthographic = true;
  current.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
  current.size = 2000.0f;
}

 

The menu item attribute might bear a little more explaining but that'll have to wait for another post.

I guess the winter makes you laugh a little slower, Makes you talk a little lower about the things you could not show her...

Read more about:

Blogs

About the Author(s)

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like