I’ve been trying to use the Cardboard back button (on screen , top left x) to exit VR mode. Before the native unity integration (5.5) I was able to just use gvrViewer.BackButtonPressed but this doesn’t seem to work now.
I’ve also tried if (Input.GetKeyDown(KeyCode.Escape)) but the app still exits.
So I’m added a Input.backButtonLeavesApp = false; but it doesn’t seem to help.
When I press the button the app exits to select new apps and just runs in background.
Any ideas?
Thanks.
I believe you can customize what happens by handling KeyCode.Escape, but you can’t stop the app from closing.
That’s too bad. It used to work perfectly with the google sdk in older versions of Unity. If you want to make an app that has both VR and nonVR modes , this is the most logical button to use to exit VR mode. Hopefully it will be fixed in future releases.
Thanks for clarifying.
Hi! I have an issue in the same way.
Using VR Cardboard package I used to create a button in UI - Screen Space Overlay to exit VR which was over the stereoscopic split screen, but with the new native cardboard SDK in Unity 5.6, the button is hidden by the split screen. In spite of this, the button works but is hidden. I’m working to find a solution.
I believe the recommended way to do what you want is to provide a button in the scene that the user can select from within VR that will notify you to switch the current VR device to None, and visa-versa.
You can check for Input.GetKeyDown(KeyCode.Escape) in Update() and perform the desired action there. That’s how we close the app in the demo scenes - please see Assets/GoogleVR/Demos/Scripts/DemoInputManager.cs.
GvrViewer.cs source does not execute on-device in the native integration, and we will be removing support for Unity versions older than 5.6 in an upcoming release.
Thanks for your reply!
Yes, we handle it like that in our app. Just wanted to give the user another option to quickly navigate back and forth if they are not in the VR headset.
Also good to know about the GvrViewer.cs not being executed on device. Now it starting to make sense. I just hope we will get Unity Native integration to the following featured:
GvrViewer.triggerd - is there an Input.GetkeyDown() equivalent to this?
GvrViewer.titlted
GvrViewer.backButtonPressed.
Thanks
I have the same request
To me it would make more sense for the x button top left in the native cardboard integration to just send an escape event for the developer to take care off. Any workarround for the exit behavior right now in Unity 5.6.0f3?
Thanks!
I second that. It’s how it worked before and it was awesome!
I can confirm that in iOS Input.GetKeyDown (KeyCode.Escape) will capture the back button event. Beware though if you Load a scene immediately when in VR mode it will crash the app. This is a separate bug.
Solution:
public void Update(){
if (Input.GetKeyDown (KeyCode.Escape)) {
StartCoroutine (VROff ());
}
}
public IEnumerator VROff () {
VRSettings.LoadDeviceByName (“None”);
yield return null;
VRSettings.enabled = false;
Debug.Log (“Disable VR”);
SceneManager.LoadScene(“Your Scene”, LoadSceneMode.Single);
}
the solution for me was to not use the new integrated sdk: Unity 5.6.0f3 Native GVR Android / iOS enabling and disabling VR - Unity Engine - Unity Discussions
Confirming also that in iOs it works as expected. instead of a close button there you get a back arrow. That makes more sense to the app we’re building. (fingers crossed for a fix for android soon)
Anybody posted a bugreport were i can vote yet? can’t seem to find one.
I have rolled back to 5.5 as there is an issue with integrated cardboard in iOS, with rendering
Any news on getting rid of the back arrow and the gear icon in cardboard view (Unity2017)?
Hey, @Kubic75 !
Did you managed to figure out this?