5
\$\begingroup\$

I'm making a game which is playable with VR and without VR. The SteamVR plugin is inside my projekt folders but no CameraRig or other SteamVR object is inside my scene.

When i start the game SteamVR starts.

How can i only activate SteamVR when i need it? (When it is checked in the settings)

\$\endgroup\$
1
\$\begingroup\$

You can disable VR support in Unity. This will disable SteamVR from starting. This can be done via code by using the VRSettings class. Specifically, the enabled value.

So, if you have two different scenes, the VR scene could set VRSettings.enabled = true; and the non-VR scene would use VRSettings.enabled = false;

Additionally, you can switch VR platforms by using something like VRSettings.LoadDeviceByName("OpenVR");.

\$\endgroup\$
2
\$\begingroup\$

For those looking in 2019, make sure that Automatically Enable VR in Edit > Preferences > SteamVR is off if you need to build also non-VR scenes

enter image description here

\$\endgroup\$
1
\$\begingroup\$

You should have cameraRig object for your SteamVR or normal Character controller for your normal game. You only require the on off these two gameobjects and need to on one gameobject at a time. [more]

\$\endgroup\$
1
\$\begingroup\$

For those looking in 2018, here is the solution for 2018.2.6f1

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.XR;

public class test : MonoBehaviour {

    void Start () {
        XRSettings.enabled = false;
    }
}
\$\endgroup\$
0
\$\begingroup\$

my oh my looks like this setting keeps moving.

Using the SteamVR Asset 2.5.0 in Unity 2019.3, the 'Auto Enable VR' setting can be found in the following Scriptable Object:

Assets/SteamVR_Resources/Resources/SteamVR_Settings.asset

\$\endgroup\$
0
\$\begingroup\$

None of these suggestions work in December 2019.

The only fix I found is that you have two cameras in two different game objects, one for VR and one for non VR. Inside the Camera settings for your Non VR Object in your Inspector you just change the Target Eye to "None (Main Display)."

This should work. It did for me. I have the same game in both standard First Person and with the HTC Vive headset. You just Instantiate the Game Object with the First Person Non VR Camera settings instead of the Game Object with the VR Camera Settings when you don't want VR in the game.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.