Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. We are looking for your feedback about Templates! Tell us about your experiences by taking our survey.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  4. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Manually initialize XR loader

Discussion in 'AR/VR (XR) Discussion' started by Clavus, Feb 9, 2020.

  1. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    46
    I've disabled the "Initialize on Startup" setting because I want to determine when to load them in script. But from what I can see I need to then load it using the XRGeneralSettings.Instance.Manager.InitializeLoader().

    However for some reason, XRGeneralSettings.Instance is always null when I have "Initialize on Startup" disabled so I can't progress. What am I doing wrong here?
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    815
    We do this all the time in our automated tests, so not sure what exactly could be the issue here.

    Are you running in Editor or in a player?
    If Editor, do you have any loaders configured for Standalone build target (we use Standalone as the default target for all in Editor play mode)?
    If in player, do you have the a loader correctly set for that build target?
    Do you have a simple,small repro project we can look at and check against?
     
  3. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    46
    Been testing a bit and it doesn't happen in 2019.3.0f6, but does happen in 2019.2.19f1 (the version I'm using to work on my game). Testing is done in-editor. OculusLoader is set up correctly.

    Included are the contents of my test project. It should throw a nullref exception on XRGeneralSettings.Instance in the InitVRScript when you run the test scene.
     

    Attached Files:

  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    815
    If it works in 19.3 I suggest using that as the version of management in 19.2 is old. On top of that, we are no longer supporting 19.2 now that 19.3 is released.
     
  5. juliens137

    juliens137

    Joined:
    Oct 2, 2017
    Posts:
    19
    Hey There, I'm running into this issue with 2019.4.9f1. I call XRGeneralSettings.Instance.Manager.InitializeLoader() and get a null reference exception. How can I fix this?
     
  6. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    815
    Are you using the latest version of management?
    Do you have a manager instance to call on? I.e. have you configured the settings for the build target your are trying to use?
     
unityunity