Search Unity

No change of VR Mode possible? (solved)

Discussion in 'AR/VR (XR) Discussion' started by Tunkali, Oct 23, 2017.

  1. Tunkali

    Tunkali

    Joined:
    Feb 5, 2013
    Posts:
    54
    It feels like a joke. Is there any Unity Version available where I can change the VR Mode? Where is the sense with LoadDevice or XRSettings.enabled when its not useable?

    I know I asked this question months before... there was the recommendation using Unity 5.5 and GoogleVR 1.1

    We are now at 2017.3 beta (my last wasteful test) and Google VR 1.100... and still no progress. Can you explain this to me? I want to make use of new features... want to build cross plattform VR Applications... But its not possible? I dont unterstand whats going on. Is cardboard not supported anymore? Would be nice to know.. because my Clients still demand it... I need to build cardboard for android, ios and gearVR... I need everytime the possibility to change between nonvr and vr...I dont want to switch between framework and unityversion in the same project...

    I would like to have an explanation... do I have to stick at old unity versions and google vr sdk? This kind of chaos is also responsible for bad VR Applications!
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    What, exactly is the issue you are running into or what are you trying to do? It should be possible to support Google VR on both Android and iOS with the same application right now.

    Gear VR is a different issue. In order to support Gear VR, there is a manifest entry added to the application to mark it as a Gear VR application. The OS catches that entry BEFORE Unity even gets a chance to do anything and forces the app into the Gear VR transition screen. The only way to support Gear VR AND Google VR right now is to create 2 applications, one for each device/store. Samsung and Oculus are working on this issue as it will also fix the issue where Gear VR applications are unable to go into and out of VR mode (again, an OS issue, not Unity).
     
    ROBYER1 likes this.
  3. Tunkali

    Tunkali

    Joined:
    Feb 5, 2013
    Posts:
    54
    Hi Joejo,

    the problem isn't GearVR. I just want to use a modern Unity-Version. The problem is Cardboard. I want to switch between VR Mode and Non-VR-Mode at Runtime. But it seems impossible with actual Unity or GoogleVR Versions. So I am forced to use an old Version of both. But I want to use modern features and the same Input-Base for GearVR. So at the moment I need to use two complete different projects and Unityversions.

    I dont understand why Daydream is so much supported, there are just some few devices and cardboard is a total mess but reaches almost any device on the market.
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    There should be no problems with switching in/out of VR in Cardboard. We test this all the time here. Can you make a real simple repro project that demos the problem and post a link to it?
     
  5. Tunkali

    Tunkali

    Joined:
    Feb 5, 2013
    Posts:
    54
    Hi Joejo,

    as I build the really small testproject I got an Idea, that I really needed to test and tataa... I solved it!

    At first I have a 2D NonVR Mainmenu... then I choose VR or NonVR Mode. When the scene is loading it recognizes which option I choose and loads the VR Mode via IENumerator.... and than nothing... until I put an WaitForSecond(0.5f) Timer!!!
    Now it's working as intended. Sometimes the orientation is a little wrong. Unity should strongly create some smallscale Tutorials or UserGuides in the documentation where such fallpits will be explained... I was loosing over two weeks because of this problem! So I was pretty desperate...

    https://1drv.ms/u/s!AnxX1Cbp1-AljloVNciE8xVohQI7

    Here is my simple project.

    Thank you for your ear! :)
     
    itsharshdeep likes this.
  6. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Vivek-Savsaiya likes this.
  7. Tunkali

    Tunkali

    Joined:
    Feb 5, 2013
    Posts:
    54
    I thought it is enough to have a yield return null after LoadDeviceByName. But it only works if I have another yield return null before XRSettings.enabled. Because I call them seperatly.

    So maybe its helpful to put this hint to this page https://docs.unity3d.com/ScriptReference/XR.XRSettings-enabled.html

    IEnumerator LoadStartVR(bool enabled)
    {
    yield return null;
    XRSettings.enabled = enabled;
    }


    Code (CSharp):
    1.  
    2.     private void Start()
    3.     {
    4.         StartCoroutine(LoadDevice());
    5.         if (VRSceneConfig.vrEnabled)
    6.         {
    7.             SetStartVR(true);
    8.             Debug.Log("VR ein: " + VRSceneConfig.vrEnabled);
    9.         }
    10.         else
    11.         {
    12.             SetStartVR(false);
    13.             Debug.Log("VR aus: " + VRSceneConfig.vrEnabled);
    14.         }
    15.     }
    16.  
    17.     private void Update()
    18.     {
    19.         if (!XRSettings.enabled)
    20.         {
    21.             if (Application.isEditor)
    22.             {
    23.                 transform.Rotate(0f, Input.GetAxis("Mouse X"), 0f, Space.World);
    24.                 transform.Rotate(-Input.GetAxis("Mouse Y"), 0f, 0f, Space.Self);
    25.             }
    26.             else
    27.             {
    28.                 transform.localPosition = InputTracking.GetLocalPosition(XRNode.CenterEye);
    29.                 transform.localRotation = InputTracking.GetLocalRotation(XRNode.CenterEye);
    30.             }
    31.  
    32.             if (Input.GetKey(KeyCode.Escape))
    33.             {
    34.                 UnityEngine.SceneManagement.SceneManager.LoadScene(0);
    35.             }
    36.         }
    37.         if (XRSettings.enabled)
    38.         {
    39.             if (Input.GetKey(KeyCode.Escape))
    40.             {
    41.                 ToggleVR();
    42.             }
    43.         }
    44.  
    45.     }
    46.  
    47.     public void ToggleVR()
    48.     {
    49.         SetVR(!XRSettings.enabled);
    50.     }
    51.  
    52.     public void SetVR(bool enabled)
    53.     {
    54.         StartCoroutine(LoadVR(enabled));
    55.     }
    56.     public void SetStartVR(bool enabled)
    57.     {
    58.         StartCoroutine(LoadStartVR(enabled));
    59.     }
    60.     IEnumerator LoadVR(bool enabled)
    61.     {
    62.         yield return null;
    63.         XRSettings.enabled = enabled;
    64.     }
    65.  
    66.     IEnumerator LoadStartVR(bool enabled)
    67.     {
    68.         yield return null;
    69.         XRSettings.enabled = enabled;
    70.     }
    71.  
    72.     IEnumerator LoadDevice()
    73.     {
    74.         XRSettings.LoadDeviceByName("cardboard");
    75.         yield return null;
    76.     }
    77. }
     
    Vivek-Savsaiya likes this.
  8. sanoend

    sanoend

    Joined:
    Mar 4, 2017
    Posts:
    1