- Home /
Blender like Camera Control Shortcuts
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;
}
}
}
}
I already know that, thanks, you can also right click on the middle cube to bring up a menu to select the orientation, but that's not the question.
T27$$anonymous$$ thanks but that has nothing to do with what I'm trying to achieve.
I'm not trying to draw a gizmo. Did you read the question?
No I asked for a way to either rotate the scene camera with keyboard through it's transform or through the top right gizmo in the scene view that we use to manipulate the camera orientation and render mode(perspective/orthographic) via scripting. I don't want to access gizmos, just that handle on the top right which you use to change the scene view camera rotation.
That's it, thanks a ton. I'll share the final version here as soon as I finish implementing all the keypad camera shortcuts of the Blender.
Convert your comment to an answer so I can select it as answered.
Can you point me to the best method / steps for using this script? Thank you.
Answer by T27M · Oct 01, 2012 at 07:14 PM
Apologies , does this answer help. http://answers.unity3d.com/questions/142295/can-scene-camera-follow-the-object.html
Just like to add I'm only trying to help as I think this would be a neat feature considering how much I use blender.