Good day
I know that there is this guide, but for some reason it does not work for me.
When the price starts, the usual menu appears, it should work with a PC and display the image on the monitor. And only after clicking on the start button, the game should be enabled in VR. But at the start of the scene, VR glasses are enabled despite the code.
Perhaps someone has already adapted an example of turning on/off VR?
How do I specify that VR should be turned off on a given scene?
Used XR iteration, WMR glasses, PC build.
This is the code I’m trying to switch with
public class VRController : MonoBehaviour
{
public bool enable;
public void Update()
{
if (Input.GetKeyDown(KeyCode.X))
{
StartCoroutine(LoadDevice("", false));
}
}
IEnumerator LoadDevice(string newDevice, bool enable)
{
XRSettings.LoadDeviceByName(newDevice);
yield return null;
XRSettings.enabled = enable;
Debug.Log(enable);
Debug.Log(newDevice);
}
}
I get the following errors, the mode does not change
Checked in Unity 2019 together with OpenVR, SteamVR, the code works, VR turns on and off without problems. Why doesn’t this work for XR iteration in Unity 2020?