I could add my own response to KeyCode.Escape, but the Cardboard is also supposed to do it when you flick it down & to the right & I wouldn’t want to re-implement that if there’s an existing thing to do.
Though I confirmed by playing some other Cardboard games that most don’t actually use the OnTilt as a back button, so I did end up just using KeyCode.Escape instead.
In SDK v0.5.2 there is now a configurable back button that can be displayed (you turn it on on the CardboardMain, which (a long with the hardware back button, and tilt) will trigger an OnBackButton event:
When the user clicked ✕ (close) or (back), the current Unity behavior is for your app to see an escape key press, which you can handle in your code by looking for the key down event:
void Update() {
if (Input.GetKeyDown(KeyCode.Escape)) {
// Android close icon or back button tapped.
Application.Quit();
}
}
In development and testing you can inject an artificial escape press using:
adb shell input keyevent KEYCODE_ESCAPE
Note, the close button was briefly broken (mentioned here) due to a Unity bug (case 893219), but is now fixed (release notes).
Verified that the above is working as expected in Unity 5.6.2p3 using GVR SDK 1.70.0. Newer releases should work the same.