informa
/
1 MIN READ
Blogs

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

Vancouver, BC, Canada
5.8.23
Producer

Bladework games

Remote (United States)
5.18.23
Senior Gameplay Engineer

University of Canterbury

Christchurch, Canterbury, New Zealand
5.17.23
Academic in Game Arts and Animation

Fred Rogers Productions

Hybrid (424 South 27th Street, Pittsburgh, PA, USA
5.19.23
Producer - Games & Websites
More Jobs   

CONNECT WITH US

Explore the
Advertise with
Follow us

Game Developer Job Board

Game Developer

@gamedevdotcom

Explore the

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio

Browse
Advertise with

Game Developer

Engage game professionals and drive sales using an array of Game Developer media solutions to meet your objectives.

Learn More
Follow us

@gamedevdotcom

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