Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Desktop or VR Game Resources. Help

Discussion in 'VR' started by MarbleDrop, Jul 19, 2021.

  1. MarbleDrop

    MarbleDrop

    Joined:
    Jul 19, 2021
    Posts:
    3
    I am currently trying to develop a game that can be played "normally" (flat screen monitor) or through VR.

    I have made VR games before and am looking into making one that can be played either way based on if the headset is plugged in or not.

    Just looking for documentation as I am struggling to find any on making a game that can be played both ways.
     
  2. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    If you want to switch between VR on and off, as it was posted recently in a thread of dug up, you do this:

    Code (CSharp):
    1.         XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
    2.         XRGeneralSettings.Instance.Manager.StartSubsystems();
    And to shut it off you do this:

    Code (CSharp):
    1.  XRGeneralSettings.Instance.Manager.StopSubsystems();
    2.                                 XRGeneralSettings.Instance.Manager.DeinitializeLoader();
    Before this will work though you have to do:

    XR Plug-in Management - > and uncheck where it says 'Initialize XR on Startup'. (just make sure you remember you did this!)

    So I'm not entirely sure yet how, but you would create a method like:

    Code (CSharp):
    1. if (usingVRHeadset()) {
    2.     //run the start code here.
    3. }
    4.  
    5. private bool usingVRHeadset() {
    6.    // STILL FIGURING THIS PART OUT, but it's something
    7.   // in the OpenXR api.
    8. }
    As of right now, I think you're gonna want to know which headset you're mainly targeting as well. Oculus for me doesn't work when using the OpenXR plugin selected in XR Plug-in Management.
     
    MarbleDrop likes this.
  3. MarbleDrop

    MarbleDrop

    Joined:
    Jul 19, 2021
    Posts:
    3
    I Haven't had troubles as of yet with my Oculus Rift S not Working with the OpenXR plugin selected. But I will let you know where I get with this. Thanks a lot! I should get around to trying this tomorrow.
     
  4. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    In XR Plug-in Management make sure to select 'Oculus' to get it working in editor play mode and when you build the EXE for windows.