I am having the biggest issue with VRsettings.enable(). All the info I find seem to take place before the 5.6 patch and nothing seems to be working the way it is suppose to.
real simple I need the first scene to be non vr and the second to be VR. I have tried all combinations to try and get this to work. I will have VR enabled with cardboard selected in Player settings. On launch I will call
public IEnumerator startup()
yield return null;
VRSettings.enabled = false;
which the splash screen will be vr (another problem ill deal with later) but the scene will load non-vr. but when I load a new scene, then on
start on the new scene I call (newDevice = cardboard)
public IEnumerator LoadDevice(string newDevice)
yield return null;
VRSettings.enabled = true;
the scene will crash on android but work fine in editor.
If i take out the Loaddevice stuff and just toggle
VRSettings.enabledit will work the first time I build it to the phone, but will crash every time there after.
Am I missing something? or is there an issue with this? did it change in 5.6? I have no idea. any help would be greatly appreciated!
I answered a very similar question some days ago. There’s some code you may find useful, so click here if you’re insterested.
First, be aware that VR in Editor is just emulated by Google SDK, and VR in android is using Unity’s Native Support, those are different things so the “if it works in editor it should work on android” logic will be not true. Keep it in mind.
If you want to start the game in Non-VR mode, configure your Player Settings like this:
It’s important to set ‘None’ as the first element in your SDKs list, this way your game will start and run in Non-VR mode (even the splash screen) until you start it manually.
To start the VR manually at run-time, you should load the VR device and set VRSettings.enable true when device is already loaded. This is really important because if you read the documentation of LoadDeviceByName(), you’ll notice that this command (quoting the docs) "loads the requested device at the beginning of the next frame. So if you set VRSettings.enable true right after call LoadDeviceByName(), it will not load correctly.
But your code is not wrong! You should only be careful if you’re calling it correctly. Considering the IEnumerator and the yield, the right way to call it will be using a Coroutine:
Hope it helps!
Oh! And one last thing: I strongly recommend you to download a newer version of Unity (try 2017.1 beta for now). That’s because Unity 5.6 is using Google NDK 1.2, which has a known leak when you go in and out of VR.