I’m trying to come up with an editor script that will let me change the scene view camera orientation with keypad keys (7 for top, 1 for front and 3 for right views) just like in Blender.
I’m able to get the right camera and get the correct keyboard events, but when I change the rotation of the scene view camera, nothing happens.
Is there a way to do this or better yet a class to access the top right gizmo in the scene view that we use to manipulate the camera orientation and render mode(perspective/orthographic)
Below is my code so far.
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Transform))]
public class BlenderCamControl : Editor {
public void OnSceneGUI() {
//TODO If no transform selected, select first transform in hierarchy
Event keyboardEvent = Event.current;
if(keyboardEvent.isKey) {
switch(keyboardEvent.keyCode) {
case KeyCode.Keypad1:
Debug.Log(Camera.current.transform.eulerAngles);
Camera.current.transform.rotation = Quaternion.Euler(new Vector3(0f, 180f, 0f));
break;
case KeyCode.Keypad3:
Camera.current.transform.rotation = Quaternion.Euler(new Vector3(0f, 270f, 0f));
break;
case KeyCode.Keypad7:
Camera.current.transform.rotation = Quaternion.Euler(new Vector3(90f, 0f, 0f));
break;
}
}
}
}