- Home /
Switching VR platforms via VRSettings
We're trying to create an app (iOS and Android) that is able to swap between Cardboard and Gyroscope control. We're doing this via a script that looks like this:
(Based on the script found in the VRSettings.LoadDeviceByName documentation.)
IEnumerator LoadDevice(string newDevice)
{
VRSettings.LoadDeviceByName(newDevice);
yield return null;
if (!(newDevice == string.Empty)) {
VRSettings.enabled = true;
}
else
{
VRSettings.enabled = false;
}
}
However we're encountering some problems with loading new devices. We're swapping the devices using a toggle script, and running the above as a Coroutine. What's been happening is on the first toggle, GoogleVR gives some errors:
05-01 10:57:21.845 7774 7774 E Unity : Error trying to call delegated method unload. null
05-01 10:57:21.846 7774 7774 E Unity : Google VR Error [Cardboard]: Exception caught while loading GoogleVR. Attempt to invoke virtual method 'java.lang.Object com.unity3d.player.l.a(java.lang.String, java.lang.Object[])' on a null object reference
05-01 10:57:21.846 7774 7800 E Unity : Google VR Error [Cardboard]: Google VR had a fatal issue while loading. VR will not be available.
The app functions as expected, just without a cardboard viewer. However, if you toggle back to gyro controls and then back to cardboard, it shows the expected cardboard viewer, but unity now spams this error to the console:
05-01 11:00:41.160 7774 7800 E Unity : OPENGL NATIVE PLUG-IN ERROR: GL_INVALID_VALUE: Numeric argument out of range
05-01 11:00:41.160 7774 7800 E Unity :
05-01 11:00:41.160 7774 7800 E Unity : (Filename: ./Runtime/GfxDevice/opengles/GfxDeviceGLES.cpp Line: 366)
After a few seconds of this, the application quits without an error code or a "App stopped unexpectedly" window. We are not using any custom plugins and are not using the GoogleVR Unity plugin as the native plugin performs all the functions we need it to (Additionally we did install the GoogleVR Plugin to see if it would fix our issues, it did not). Any help at all would be great, thanks.
I'm getting the same problem. I'm running Unity 5.6.0f3 Personal (64bit) on Windows 10. I created my very first Hello World Gvr$$anonymous$$ain Daydream app with a grand total of around 10 lines of code to create a handful of prefab geometry.
The app runs fine on Android 7.1 PixelXL for about 10 seconds while spam$$anonymous$$g the following error message, and then it freezes (but I didn't see the Android crash dialog).
05-20 18:49:04.335 1101 6414 I nanohub : queueFlush: sensor=49, handle=41
05-20 18:49:04.344 6698 6733 W Adreno-GSL: <gsl_ldd_control:477>: ioctl fd 44 code 0xc0140933 (IOCTL_$$anonymous$$GSL_TI$$anonymous$$ESTA$$anonymous$$P_EVENT) failed: errno 24 Too many open files
05-20 18:49:04.344 6698 6733 W Adreno-GSL: <ioctl_kgsl_syncobj_create:3269>: (2d, 15, 26152) fail 24 Too many open files
05-20 18:49:04.345 6698 6733 E Unity : OPENGL NATIVE PLUG-IN ERROR: GL_INVALID_VALUE: Numeric argument out of range
05-20 18:49:04.345 6698 6733 E Unity :
05-20 18:49:04.345 6698 6733 E Unity : (Filename: ./Runtime/GfxDevice/opengles/GfxDeviceGLES.cpp Line: 366)
05-20 18:49:04.345 6698 6733 E Unity :
05-20 18:49:04.348 1101 6414 I nanohub : queueFlush: sensor=50, handle=42
05-20 18:49:04.354 6698 6733 E Surface : dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -2147483646
05-20 18:49:04.354 6698 6733 I Adreno : DequeueBuffer: dequeueBuffer failed
05-20 18:49:04.363 6698 6733 I Unity : NullReferenceException: Object reference not set to an instance of an object
05-20 18:49:04.363 6698 6733 I Unity : at StereoController.OnPreCull () [0x00000] in <filename unknown>:0
05-20 18:49:04.363 6698 6733 I Unity :
05-20 18:49:04.363 6698 6733 I Unity : (Filename: Line: -1)
05-20 18:49:04.363 6698 6733 I Unity :
05-20 18:49:04.374 1101 1403 D ActivityRecognitionHAL: OnFlush published
@jlfreund I've converted your answer to a comment (I can't remove it), you can remove your other comment, I guess... this is confusing :/