Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Bug Oculus Quest 2 and Quest Link failing to start

Discussion in 'VR' started by veddycent, Sep 14, 2022.

  1. veddycent

    veddycent

    Joined:
    Jul 22, 2013
    Posts:
    109
    Hi all,

    I'm having real difficulty migrating to the new XR system in 2021.
    I'm only using the Quest 2 on Quest Link and only need the headset to work when the user enables it via UI. I only need the headset to work, so don't need any controllers etc.

    I have the XR Plugin and Oculus plugin installed with the latest versions.
    Oculus is selected in Plug-in Providers under XR Plug-In Management

    I have the Oculus software running and Quest Link selected.
    Initialize XR on Startup is off.

    This is the code I have attached to the UI button.

    Code (CSharp):
    1. IEnumerator StartXR()
    2. {
    3.     Debug.Log("Initializing XR...");
    4.     yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
    5.  
    6.     if (XRGeneralSettings.Instance.Manager.activeLoader == null)
    7.     {
    8.         Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
    9.     }
    10.     else
    11.     {
    12.         Debug.Log("Starting XR...");
    13.         XRGeneralSettings.Instance.Manager.activeLoader.Start();
    14.     }
    15. }
    16.  
    17. void StopXR()
    18. {
    19.     Debug.Log("Stopping XR...");
    20.  
    21.     if (XRGeneralSettings.Instance.Manager.activeLoader != null)
    22.     {
    23.         XRGeneralSettings.Instance.Manager.activeLoader.Stop();
    24.         Debug.Log("XR stopped completely.");
    25.     }
    26.  
    27.     Camera.main.ResetAspect();
    28. }
    This works the first time I run it in the editor but after I always get this error message:

    Failed to set DeveloperMode on Start.

    It's as though something isn't being reset after exiting play mode.

    Someone else asked on the forums but was never resolved:
    https://forum.unity.com/threads/stop-and-restart-xr-plugin-management.1145918/#post-7356980

    I'm only building for Windows.

    Unity: 2021.2.4f1
    XR Plugin: 4.2.1
    Oculus XR Plugin: 1.11.2
    OpenXR Plugin: 1.2.8

    Has anyone else come across this issue and manage to fix it?
     
  2. vincentwing

    vincentwing

    Joined:
    Aug 7, 2017
    Posts:
    2
    Yes, I had this problem. Turned out I forgot to run "StopXR" at the end of a session (ended up working when I put it in "OnDestroy").

    My script is a little bit different:


    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using UnityEngine.XR.Management;
    4.  
    5. public class VRInitializer : MonoBehaviour
    6. {
    7.     private void Start()
    8.     {
    9. EnableXR();
    10.     }
    11.     private void OnDestroy()
    12.     {
    13.         DisableXR();
    14.     }
    15.     public void EnableXR()
    16.     {
    17.         StartCoroutine(StartXRCoroutine());
    18.     }
    19.     public void DisableXR()
    20.     {
    21.         Debug.Log("Stopping XR...");
    22.         XRGeneralSettings.Instance.Manager.StopSubsystems();
    23.         XRGeneralSettings.Instance.Manager.DeinitializeLoader();
    24.         Debug.Log("XR stopped completely.");
    25.     }
    26.  
    27.     public IEnumerator StartXRCoroutine()
    28.     {
    29.         Debug.Log("Initializing XR...");
    30.         yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
    31.  
    32.         if (XRGeneralSettings.Instance.Manager.activeLoader == null)
    33.         {
    34.             Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
    35.         }
    36.         else
    37.         {
    38.             Debug.Log("Starting XR...");
    39.             XRGeneralSettings.Instance.Manager.StartSubsystems();
    40.         }
    41.     }
    42. }
     
    Aento, antonsem and veddycent like this.
  3. uvavoo

    uvavoo

    Joined:
    Oct 15, 2007
    Posts:
    60
    Brilliant, thanks for that, this issue was driving me mad. Do you think this is a Unity problem, an Oculus problem or a problem with OpenXR? Thanks again mate.
     
  4. Kero-F

    Kero-F

    Joined:
    May 19, 2023
    Posts:
    1

    That fixed the issue for me. Thanks