Search Unity

How to start the game without VR with the new XR stack?

Discussion in 'AR/VR (XR) Discussion' started by demonixis, Jun 4, 2020.

  1. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Hello,

    With the old XR stack it was easy to start the game without VR by passing the vrmode None parameter. How does it works with the new XR stack? Do we have a special parameter? Or do I have to do it by myself in the code?

    Thanks.
     
  2. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
  3. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Thanks a lot!
     
  4. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    But how can I choose a specific SDK without removing them from the list?
     
  5. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    I don't have enough headsets with me to check, but I believe:

    Using the settings manager instance from the above docs:

    Code (CSharp):
    1.    var loaders = settingsManager.loaders;
    2.    // Add/Remove/Reorder loader list;
    3.    settingsManager.loaders = loaders;
    i.e. modify the "loaders" list then re-assign it.

    Although Unity's docs are definitely wrong here - one page says that operation is required, the other page says it's impossible/illegal (at the compiler level) :D.
     
  6. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    The problem is that if you change the loader variable, it changes the scriptable object and its saved like that. That means next time the loaders variable only contains one loader. It's the behaviour in the editor.

    A hack could be to copy the loader list and put it with good values when OnDestroy or OnApplicationClose are called.
     
  7. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    In player builds it should be fine, of course - which I guess is the only variant they tested?

    The manual restore sucks but should work fine. We've had to do that for 10 years now with Unity Terrain (bad design decision up-front, they made some of the terrain config "an Asset", and never finished writing their API/implementation, so everyone has to manually restore the Asset data when leaving play mode. 10 years!).
     
  8. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    I do that for Scriptable Render pipeline modifications during runtime too :/ Well looks like I'm good to save and restore the list content. It's a steam game, I can't take a risk..
     
  9. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Changing the order and using InitializeLoader doesn't work well for me. I got a black screen in the editor, when I stop the editor it's freezed :/

    I would like a working example of how to start and stop manually the new XR stack because for what I tried, it doesn't work.
     
  10. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    I think @mfuad is one of the team working on this stuff - hopefully he can help.

    (I've asked about this a few times, and haven't got an answer from anyone at Unity on it, so I'd love to get an official response. Getting it to "not autostart" is OK, but as you're finding, the rest is ... just not really documented, as far as I can tell, and I know some people have got it to work, but it's not obvious how)
     
  11. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Well it could be great because right now, I can't use this system :/ The OpenVR packages crashes my build too.
    I'll disable VR for first beta test, I hope Unity will answer the question :)
     
  12. XargonInSpace

    XargonInSpace

    Joined:
    Nov 5, 2018
    Posts:
    4
    Anyone got any experience with the Cardboard Plugin? we're having some issues - Initializing the loader will cause our magic window scene to not draw.
     
  13. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    Looking at the code for XRManagerSettings the property setter for the List of loaders is guarded like:
    #if UNITY_EDITOR
    set { m_Loaders = value; }
    #endif

    which I think ultimately means there's not going to be a way reorder those loaders at runtime if your not running in the editor (I don't see any other api there that lets you manipulate that list).

    I'm not really sure why that setter is guarded like that - if anything due to the serialization issue isn't it more of a problem to be setting the loaders while in the editor?

    I guess to manually handle XR plugin loading you pretty much have to copy the code out of XRManagerSettings into your own class where you can have a mutable list to work with instead. :/