- Home /
VRSettings.supportedDevices not populating if None is the first SDK.
Using --- Unity3D 5.4.0.b10
What happened
When you add all of the "Virtual Reality SDKs"
Split,
OpenVR
Stereo
Oculus
None
If you have "None" at the very top of the list, VRSettings.supportedDevices is Null and will not populate with the list of devices.
where supportedDevices is a public var String[] array.
I figured that because it was looping through the list and looking for available devices to connect to, that maybe it was disabling VR entirely and thus not updating, but setting VRSettings.enabled = true; didn't seem to help either.
only way supportedDevices is populated, is if you change None, to a different entry (other than the first).
How we can reproduce it using the example you attached
(using Javascript)
static var myDevice : String[]; function Start() { myDevice = VR.VRSettings.supportedDevices; for (var i = 0; i < 4; i++) { Debug.Log(myDevice[i]); } }
I submitted this as a bug, just in case someone else is having a similar issue, just changing 'None' to any entry other than the 1st should resolve this. then if you need for the initial device to be None at startup,
function Start() {
VR.VRSettings.loadedDevice = VR.VRDeviceType.None;
}
Also...
if the 1st (player setting) VR SDK is "None", the VRSettings.enabled will not enable.
if the 1st (player setting) VR SDK is "None", and deviceLoaded is changed to Split,
VRSettings.enable will not enable outside of a function.
VRSettings.enable will not enable in Start()
VRSettings.enable does enable in Update() but only after the 2nd Update() call.
Also, if you are in Editor and not in a build, and Stereo is before any other SDK entry,
it will not work, and stops looking for a new device to fall back on. In that event...
VRSettings.enable will not enable in any function.
If you get 2 Gray screens in split mode, (or a gray and a black screen),
try turning off --- "Single-Pass Stereo Rendering"
If you set VR.VRSettings.loadedDevice = VR.VRDeviceType.Split; or presumably
any other device, while VR.VRSettings.enabled = false; when it is enabled again,
it will cause the screen to flicker in split screen, and then resets back to the single screen.
Make sure you enable the VRSettings
before you change the device.
also, take note that there is a delay when enabling the VRSettings, i measured it
at about 3 onGUI calls, before it enables... then, it is safe to set the device.
For testing, I used this (javascript) :
#pragma strict
static var T_V : boolean = false;
static var T_V2 : boolean = false;
static var T_V3 : boolean = false;
//VR.VRSettings.enabled = true;
Debug.Log("- Init - VR Active? " + VR.VRSettings.enabled);
function Start () {
VR.VRSettings.enabled = true;
Debug.Log("- Start - VR Active? " + VR.VRSettings.enabled);
}
function Update () {
//VR.VRSettings.enabled = true;
//Debug.Log("- Update- VR Active? " + VR.VRSettings.enabled);
}
function OnGUI() {
T_V = GUI.Toggle(Rect(50, 50, 50, 50), T_V,"VR1");
T_V2 = GUI.Toggle(Rect(150, 50, 50, 50), T_V2,"VR2");
T_V3 = GUI.Toggle(Rect(250, 50, 50, 50), T_V3,"VR OFF");
if (T_V) {
//VR.VRSettings.showDeviceView = true;
VR.VRSettings.enabled = false;
VR.VRSettings.loadedDevice = VR.VRDeviceType.Split;
VR.VRSettings.enabled = true;
Debug.Log("- VR1 - VR Active? " + VR.VRSettings.enabled);
T_V = false;
}
if (T_V2) {
//VR.VRSettings.showDeviceView = true;
VR.VRSettings.enabled = true;
VR.VRSettings.loadedDevice = VR.VRDeviceType.Split;
Debug.Log("- VR2 - VR Active? " + VR.VRSettings.enabled);
T_V2 = false;
}
if (T_V3) {
VR.VRSettings.loadedDevice = VR.VRDeviceType.None;
T_V3 = false;
}
}
In the event you have an older graphics card / older VR software, and VR doesn't seem to be working in your Build, try running your program in dx9 with a preset vrmode:
vrProgram.exe -force-d3d9 -vrmode Split
vrProgram.exe -force-d3d9 -vrmode Stereo
vrProgram.exe -force-d3d9 -vrmode Oculus
vrProgram.exe -force-d3d9 -vrmode OpenVR