# How can I make the X button in the Cardboard XDK exit VR mode?

When I build a game using Unity 2017.2.0f3 and the Cardboard SDK (using XR settings) and run it on my device, I see two controls overlaid on the screen, a cross and a gear:

Currently, pressing the cross control does nothing. I'd like to make the cross exit VR mode when pressed.

When clicking ✕ (close), your Unity app should get an escape key press notification & you should be able to handle it the same way as an actual key down event. For example, to quit, you would do this:

void Update(){
if(Input.GetKeyDown(KeyCode.Escape)){
// close icon pressed, place appropriate code here
Application.Quit();
}
}


There was an error that prevented this; make sure Unity & your various SDKs are patched & up to date.

• Someone anonymously edited attempted to edit this answer with the statement "it is not work, I think it maybe block be due to Cardboard SDK." If you run into a problem with the answer, leave some feedback (as a comment, not an edit) describing the situation. – Pikalek Feb 28 at 14:45

It looks like a simple UI. I suppose you need to find right Canvas in the Unity3d Editor window and add OnClickEvent to these elements (cross and settings icons). If cross is containing button component you will simply need to add OnClickEvent that will escape VR mode.

• this canvas generated by Unity. How can I have access to it? – GuardFromUA Mar 1 '18 at 13:11
• You need to find this Canvas in Unity3d Hierarchy window. If you see these elements in Editor window mode (Scene) just click on them and they will be selected in hierarchy window. – Bogdan Mar 1 '18 at 13:44
• I can't view it in Unity3d Hierarchy window. It is generated by Unity automatically on mobile device. What I need is some access to Unity automatically generated UI(VR UI, in this case). – GuardFromUA Mar 1 '18 at 13:54
• @GuardFromUA it's probably an old gui system. You should find the code that displays those. I'm not familiar with old system but as far as my experience goes it's created via code. – Candid Moon _Max_ Mar 1 '18 at 14:03
• @CandidMoon I searched and can't find it... – GuardFromUA Mar 1 '18 at 14:07