Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Toggle SteamVR for Non-VR builds/testing

Discussion in 'AR/VR (XR) Discussion' started by DPirag, Jul 25, 2016.

  1. DPirag

    DPirag

    Joined:
    Dec 5, 2012
    Posts:
    1
    Hey, does anyone know if there's a way to easily add/remove SteamVR HMD tracking and options? It would help a lot if I could, for example, disable the HMD when I simply want to navigate my level designs on the monitor, or if I could export the game for Non-VR viewing so my teammates without a headset could get an idea. The workflow of making a change, then being forced to get up and put on my headset is pretty annoying and in the end just inefficient.

    If you have any ideas I'd love to hear it, thanks.
     
    blox5000 likes this.
  2. atiaxi

    atiaxi

    Joined:
    Jun 27, 2015
    Posts:
    1
    In 5.3, I'd simply put another camera in the scene; whenever I needed to test something non-vr, I'd just disable the steamvr camera and enable the other one, then swap back when I wanted to go through the 'headset shuffle'.

    I don't know how/if that works in 5.4; I haven't done VR testing in it yet, but my initial reading of the notes indicates that it'll treat (almost) all cameras as VR cameras so that may no longer work. My fallback before discovering the enable/disable trick was to prop the headset up in a reasonable location but that's easier said than done.
     
  3. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    You can simply enable/disable VR mode through script to disable tracking:

    http://docs.unity3d.com/ScriptReference/VR.VRSettings-enabled.html

    Optionally you could also completely disable VR by disabling the checkbox in the PlayerSettings but by using the API you can do this more on-demand. In the case where you mention exporting the game to other teammates without a headset - I would recommend adding VR device 'None' to the list of supported VR devices. In the event Unity starts up and cannot find a Vive HMD it will fallback to non-VR mode. You can also put None at the top of the list and start in normal mode and transition to VR through the API.
     
  4. bzor

    bzor

    Joined:
    May 28, 2013
    Posts:
    35
    sorry to revive this, but I'm finding that setting it to None at the top then trying to enable with VRSettings.enabled = true doesn't work.. When I set it to true it logs false on the next line. Setting it to OpenVR then disabling it does work, but I'd rather go the other way.. any insight here?

    thanks!
     
  5. chantey

    chantey

    Joined:
    Mar 5, 2017
    Posts:
    49
    just an update for 2018.3...
    Its also handy to have XR related Game Objects to be disabled also:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.XR;
    3.  
    4. public class XRManager : MonoBehaviour
    5. {
    6.  
    7.     public bool enableXR;
    8.     public GameObject[] XRGameObjects;
    9.  
    10.     void Awake()
    11.     {
    12.         XRSettings.enabled = enableXR;
    13.         foreach (var go in XRGameObjects)
    14.         {
    15.             go.SetActive(enableXR);
    16.         }
    17.     }
    18. }
    19.  
     
    AlanPT likes this.