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

How to test in Unity Editor?

Discussion in 'AR/VR (XR) Discussion' started by Wallawocko, Nov 15, 2016.

  1. Wallawocko

    Wallawocko

    Joined:
    Nov 1, 2015
    Posts:
    25
    Hey guys,

    I feel like i'm missing something simple here.
    I've developed for the Google Cardboard extensively, and you can preview your build within Unity and by holding the "alt" key, can move your mouse and rotate the cameras as you would within VR. This makes testing and developing Gaze tracking apps very easy.

    I dont seem to see this sort of functionality built in for the Gear VR. Am i missing something? Does someone have a script they could share that manages this?

    Thanks!
     
  2. Wallawocko

    Wallawocko

    Joined:
    Nov 1, 2015
    Posts:
    25
    Just made my own script. Written here if anyone else needs it..

    Code (CSharp):
    1. void Update() {
    2.         #if UNITY_EDITOR
    3.         Quaternion rot = camera.transform.rotation;
    4.         bool rolled = false;
    5.  
    6.  
    7.             if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) {
    8.                 mouseX += Input.GetAxis("Mouse X") * 5;
    9.                 if (mouseX <= -180) {
    10.                     mouseX += 360;
    11.                 } else if (mouseX > 180) {
    12.                     mouseX -= 360;
    13.                 }
    14.                 mouseY -= Input.GetAxis("Mouse Y") * 2.4f;
    15.                 mouseY = Mathf.Clamp(mouseY, -85, 85);
    16.  
    17.  
    18.             rot = Quaternion.Euler(mouseY, mouseX, mouseZ);
    19.             camera.transform.rotation = rot;
    20.             }
    21.            
    22.         #endif
    23.     }
     
  3. Martinez-Vargas

    Martinez-Vargas

    Joined:
    Jun 24, 2016
    Posts:
    39
    Hello Friend.
    In the oculus SDK there are two types of camera, the first is OVRCameraRig, this does not allow to have a preview of the scene in reproduction, you have to do manual from the inspector playing with the rotation axes.
    The second one is OVRPlayerController, this camera if it allows to have a preview since it is a camera for games in first person, you can use it like the first camera but deactivating the gravity function.