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

Google CardBoard: How do I rotate the orientation?

Discussion in 'AR/VR (XR) Discussion' started by tempworkacc1, Oct 6, 2015.

  1. tempworkacc1

    tempworkacc1

    Joined:
    Sep 9, 2015
    Posts:
    4
    I need to show the scene in a tablet that will respond like a phone but with the VR MODE off. the problem is that in the tablet it will set the orientation in a way that I have to move it in portrait mode and not in landscape mode ( even though in a phone it will work in landscape mode like it should ).
    Is there any way to control it? ( rotate it by 90 degrees perhaps? )
     
    Last edited: Oct 6, 2015
  2. tempworkacc1

    tempworkacc1

    Joined:
    Sep 9, 2015
    Posts:
    4
  3. visionnaireMedia

    visionnaireMedia

    Joined:
    Jul 25, 2016
    Posts:
    17
    I'm pretty sure you won't care anymore, but for any other person looking for the answer: http://stackoverflow.com/questions/32200052/unity-cardboard-orientation-landscape-right-upside-down

    The code itself is:
    Code (CSharp):
    1. private Quaternion fixOrientation;
    2.  
    3. public override void UpdateState() {
    4.   GetHeadPose(headData, Time.smoothDeltaTime);
    5.   ExtractMatrix(ref headView, headData);
    6.   headPose.SetRightHanded(headView.inverse);
    7.  
    8.   // Fix head pose based on device orientation (since native code assumes Landscape Left).
    9.   switch (Input.deviceOrientation) {
    10.     case DeviceOrientation.LandscapeLeft:
    11.       fixOrientation = Quaternion.identity;
    12.       return;
    13.     case DeviceOrientation.LandscapeRight:
    14.       fixOrientation = Quaternion.Euler(0, 0, 180);
    15.       break;
    16.   }
    17.   headPose.Set(headPose.Position, headPose.Orientation * fixOrientation);
    18. }
     
    Grakou likes this.
  4. JasmineJas

    JasmineJas

    Joined:
    Jun 2, 2016
    Posts:
    9
    Check your Screen - Rotation settings in the Android control panel, maybe the 270 degree option is disabled.