Search Unity

Question Can't switch VR back on

Discussion in 'XR Interaction Toolkit and Input' started by lz7cjc, Mar 21, 2021.

  1. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    538
    Hi
    I need to toggle between VR and standard format for my app. I start in 2d then switch to VR which works fine. I then go back to 2D, again no problem but when I then try to go back into VR, the screen doesn't split and I have to restart my app as I lose control over the scene (gvrpointer doesn't work)

    I am using the following code to switch on VR:
    Code (CSharp):
    1.  public void Start()
    2.     {
    3.  
    4.         StartXR();
    5.     }
    6.     public void StartXR()
    7.     {
    8.         Debug.Log("VR starting");
    9.         XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
    10.         XRGeneralSettings.Instance.Manager.StartSubsystems();
    11.     }
    12.  
    and this to stop it
    Code (CSharp):
    1.     void Start()
    2.     {
    3.         if (XRGeneralSettings.Instance.Manager.activeLoader != null)
    4.         {
    5.             XRGeneralSettings.Instance.Manager.activeLoader.Stop();
    6.             XRGeneralSettings.Instance.Manager.activeLoader.Deinitialize();
    7.             Debug.Log("XR stopped completely.");
    8.         }
    9.     }
    Strangely whilst I get the debug from StartXR() each time i move in and out of VR in the Editor I don't ever see "XR stopped completely" but I do switch to standard mode.

    I can toggle between the screens in Editor and everything works fine. This problem only occurs on Android and iPhone.

    thanks