So far the Google VR SDK is just frustrating to work with.
Even with Native SDK support in Unity 5.6 you still need the GVR SDK package implemented to be able to use the reticle pointer.
GvrViewer.VREnabled doesn’t work with native implementation so when it is an Android build / iOS build it requires to set VRSettings.Enabled
We have an app in development where the user should be able to engage into VR mode when the user wants to like clicking on a button.
When the user presses the X at the left top as he/she wants to exit VR mode, we as developers want to tell it to close the VR Mode by setting VRSettings.Enabled = false.
Though the native integration is closing the app no matter what. We have no control of what the X is supposed to do.
Even an Application.CancelQuit() call doesn’t work to cancel the quitting.
We can’t seem to handle the event the X button gives us.
So we can get in to VR whenever we want, just not get out of it.
Is there a solution for this that we’re not aware of?
Meanwhile I was able to start my app in a non vr-mode and to switch to cardboard-mode without any additional plugins:
So after adding “None” to Virtual Reality SDKs on position 0 and “Cardboard” to position 1, following script allows at least to enable cardboard:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VR;
public class EnableVR : MonoBehaviour {
public string[] devices;
void Awake () {
devices = VRSettings.supportedDevices;
}
public void Enable_VR (bool isEnabled) {
if (isEnabled)
StartCoroutine("LoadVRDevice");
else
StartCoroutine("LoadStandardDevice");
}
IEnumerator LoadStandardDevice()
{
VRSettings.LoadDeviceByName(devices[0]);
yield return null;
VRSettings.enabled = false;
}
IEnumerator LoadVRDevice()
{
VRSettings.LoadDeviceByName(devices[1]);
yield return null;
VRSettings.enabled = true;
}
}
Now the question is:
How to get the cardboard X not to close the app but to call “Enable_VR(false)”?
Or - How to completely disable that X (and use a custom button instead)?
I am suffering through the same issue. On the google vr android sdk there is a method setCloseButtonListener that allows you to override that method but can’t figure out how to do it within unity. Is there a way to access the underlining implementation of google vr? Can you use the VRDevice.NativePtr to access it from native code?
Along side of that is there an easy way to determine if daydream is supported? Because if you implement @Cascho01 process of switching from None to cardboard then you wouldn’t have support for daydream. And it seems that if you try setting it to daydream it just fails with a log saying it isn’t supported and doesn’t fall back to cardboard.
Also struggling with the same issue. Perhaps at an even more fundamental level:
With Unity 5.6f3 and gvr-unity-sdk v.1.30, here is my process and problems:
Open Unity 5.6f3; create a new project
Assets > Import Package… > Custom Package… and select “GoogleVRForUnity.unitypackage”
Import everything
Change player settings to enable “Virtual Reality Supported”
add “Cardboard” under "
Open this scene “GoogleVR>Demos>Scenes>GVRDemo”; press Play in Unity
Problems:
I get an error in the game window that says To use the controller, please upgrade to a version of Unity with the GVR native integration. Isnt Unity 5.6f3 the latest version and doesn’t it have native GVR integration?
I’m not able to move around with the mouse; shouldn’t I be able to do that, for CardBoard?
There are 2 or 3 other threads with the exact same question. So I may as well add myself to this one too.
The short answer is that currently there is no way to developers to use the X button that shows up when in VR mode. We need to implement a button in the vr view (3d view) to exit vr mode. Hopefully that will change back to what it used to be , which is full control over what the app does when a user press the X button
We used 5.5.1 and GVR 1.4 to allow going into and out of VR - too many bugs with the 5.6 native approach.
However that X button appears to do nothing at all so don’t know why it even appears
It is still possible to get the non native Google VR version to run:
Find in all files (in monodevelop or visual studio or another editor) " UNITY_HAS_GOOGLEVR " (without ") and replace it with “SCREW_YOU”. (or any other tag you are not using)
find the text “UNITY_5_6” in the file GvrBuildProcessor and replace it as well with “SCREW_YOU”
find the line "scale *= 2.0f; " and delete it (or replace it a comment like “//DO NOT DESTROY MY PERFORMANCE”)
Find the files “GVRBackwardsCompatibility.unitypackage” and “GVRiOSNativeCompatibility” in the folder GoogleVR in the unity project and double click them (and press yes on import)
Change the player settings. Virtual Reality Supported has to be set to FALSE (no cross)
Also in the player settings put “Multithreaded Rendering” to off. (You can try graphics jobs experimental if you want instead).
restart unity
if building for IOS copy paste the files “CardboardSDK.bundle”, “GoogleKitCore.bundle”, “GoogleKitDialogs.bundle”, “GoogleKitHUD.bundle” and “MaterialRobotoFontLoader.bundle” from an unity 5.5 project into yours.
You can find them under Plugins/iOS (and put them into that folder in the new Unity Version).
After this you are able to build using the google cardboard sdk 1.4 under Unity 5.6
Can confirm this works on Android. You are a lifesaver! Hopefully, these errors are soon fixed on the next patches. (I had the same errors in Unity 5.6.1f1).