- Home /
 
Setting the SceneView View Angle/Position?
Hi there.. I Want to write my own Tilemap Editor.
Now i need the Scene View to show the Map as i want: Orthographic, Topdwon, with a Camera Y position of 256.
I managed to do the Rotation and orthographic.
Now..:
How can i change the position of the Scene View Camera, to show my Map Topdown. Means.. On Y position 256? It would be enough to set the Scene View to it´s "TOP" Setting from the Scene Gizmo..
How to Set this options (including rotation and orthographic), everytime it gets changed? Cause OnGUI and OnSceneGUI only refresh the code, when clicking on them ._.?
I´m hoping for some answers :)
Answer by Alexphauge · Nov 27, 2014 at 02:49 PM
Hey there,
A very late answer, but I was looking for something similar myself. Now I've found it I'll share the solution so someone else might find it and benefit from it.
In my case I wanted the gameObject to stay selected while holding down CTRL/Control and even though I left clicked in different places in the sceneview, I also wanted to go into my "edit" mode while holding down CTRL.
     private void OnSceneGUI()
     {
         Event e = Event.current;
 
         // We're holding down CTRL
         if (e.control)
         {
             // Used to change inspectorGUI
             _holdingControlDown = true;
 
             // Makes sure to save the current camera position, rotation and orthographic setting
             if(_cameraPositionBeforeEditMode == Vector3.zero)
             {
                 _cameraOrthoBeforeEditMode = SceneView.lastActiveSceneView.orthographic;
                 _cameraRotBeforeEditMode = SceneView.lastActiveSceneView.rotation;
                 _cameraPositionBeforeEditMode = SceneView.lastActiveSceneView.pivot;
 
                 Vector3 newPivot = new Vector3(
                     accessableGridRef.transform.position.x,
                     accessableGridRef.transform.position.y + 100f,
                     accessableGridRef.transform.position.z);
 
                 SceneView.lastActiveSceneView.pivot = newPivot;
             }
 
             // Removes the default "handle" from Unity's tools
             if (Tools.current != Tool.None)
             {
                 _lastTool = Tools.current;
                 Tools.current = Tool.None;
             }
 
             // If the user holds down ctrl while clicking with left mouse button
             if (e.isMouse && e.button == 0 && e.type == EventType.mouseDown)
             {
                 Debug.Log("Pressed left mouse button while holding ctrl");
 
                 // I'm going to change some stuff here later.
             }
 
             // Set camera to iso from top point
             SceneView.lastActiveSceneView.orthographic = true;
             SceneView.lastActiveSceneView.rotation = Quaternion.Euler(90, 0, 0);
             // You can also set position here by going:
             // SceneView.lastActiveSceneView.pivot = new Vector3();
 
             // Keep selection of Level, no matter what I click in the sceneView
             Selection.activeGameObject = accessableGridRef.gameObject;
 
             // If we let go of CTRL, remember to debrief everything and put stuff back to "normal"
             _debriefEditorMode = true;
         }
         else
         {
             // Resets everything back to the view it had before
             if (_debriefEditorMode)
             {
                 _holdingControlDown = false;
 
                 if (Tools.current == Tool.None)
                 {
                     Tools.current = _lastTool;
                 }
 
                 SceneView.lastActiveSceneView.rotation = _cameraRotBeforeEditMode;
                 SceneView.lastActiveSceneView.orthographic = _cameraOrthoBeforeEditMode;
                 SceneView.lastActiveSceneView.pivot = _cameraPositionBeforeEditMode;
 
                 _cameraPositionBeforeEditMode = Vector3.zero;
                 SceneView.lastActiveSceneView.Repaint();
 
                 _debriefEditorMode = false;
             }
         }
     }
 
              Your answer
 
             Follow this Question
Related Questions
Unity Scene View's right-click + WASD doesn't look 3D anymore? 2 Answers
How can I make a custom 3d editor within the Unity editor? 1 Answer
Editor Camera Orthograpric Control 5 Answers
Scene view camera reverts to defaults when another window is minimized 1 Answer
turn off selection in the Scene View 0 Answers