informa
2 min read
article

Reset Scene View

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

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...

Latest Jobs

Treyarch

Playa Vista, California
6.20.22
Audio Engineer

Digital Extremes

London, Ontario, Canada
6.20.22
Communications Director

High Moon Studios

Carlsbad, California
6.20.22
Senior Producer

Build a Rocket Boy Games

Edinburgh, Scotland
6.20.22
Lead UI Programmer
More Jobs   

CONNECT WITH US

Register for a
Subscribe to
Follow us

Game Developer Account

Game Developer Newsletter

@gamedevdotcom

Register for a

Game Developer Account

Gain full access to resources (events, white paper, webinars, reports, etc)
Single sign-on to all Informa products

Register
Subscribe to

Game Developer Newsletter

Get daily Game Developer top stories every morning straight into your inbox

Subscribe
Follow us

@gamedevdotcom

Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more