Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Customised Editor Camera - Orbit Z Axis

Discussion in 'Scripting' started by magnetix, Jun 1, 2015.

  1. magnetix

    magnetix

    Joined:
    Apr 4, 2010
    Posts:
    102
    Hi,

    Ive been tinkering with Editor scripting and have been able to get access to the SceneView camera. What I'm trying to do is to change the behaviour so that the default mouse/keyboard interaction in the editor orbits the Z axis instead of the Y axis. I have a game that resides primarily in the XY plane, so the default camera orbit is inconvenient for general scene navigation. I am decent at 3D maths, but what I am wondering is this:

    • Should I attempt to remap the window mouse input to the other axis?
    • Should I apply a pre-rotation the entire scene using the camera matrix to alter the rendered game-world's orientation so that the usual input is essentially transposed onto the correct axis?
    • Is there some other way to do this that I am overlooking? It does not seem to be available anywhere that I've seen.
    Here's some code I've been playing with, it's not doing exactly what I want at this stage:

    Code (CSharp):
    1. void OnFocus()
    2. {
    3.     SceneView.onSceneGUIDelegate -= this.OnSceneGUI;
    4.     SceneView.onSceneGUIDelegate += this.OnSceneGUI;
    5. }
    6.  
    7. void OnDestroy()
    8. {
    9.     SceneView.onSceneGUIDelegate -= this.OnSceneGUI;
    10. }
    11.  
    12. // Update is called once per frame
    13. private void OnSceneGUI (SceneView sceneView)
    14. {
    15.     // sceneView.camera.worldToCameraMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis (180f, Vector3.right), Vector3.one);
    16.     // camEulers = sceneView.camera.transform.eulerAngles;
    17.     // sceneView.camera.transform.eulerAngles = new Vector3 (camEulers.y, camEulers.x, camEulers.z);
    18.     Repaint ();
    19. }
    20.  

    Thank you for considering this problem with me.
     
  2. magnetix

    magnetix

    Joined:
    Apr 4, 2010
    Posts:
    102
    Have to bump this as I'd really like some help, thanks.
     
  3. magnetix

    magnetix

    Joined:
    Apr 4, 2010
    Posts:
    102
    Just one more try - if anyone can help out that would be great. Thanks.