Search code examples
androidbuttonunity-game-engineaugmented-realityvuforia

Vuforia Unity3D: how to make on-screen close/back/quit button?


I just started making AR application.

I made the first, working, could not be happier. But I have a problem: I do not know how to insert a button on the screen that will close the app when user tap (yes, tap, I want to work on Android) on it.

So when I run the application, which I made in Unity, I see only camera. I want to put in the corner of the screen a button that will always stand there and that will close the application. This button I need because I can not close the application using the "Back" button.

I use a Nexus 7 2013 (android 5.0) because only there application works. On the Galaxy S2 4.4.4 I have always crashes (can't run, only splash screen). But that is another problem :)


Solution

  • You can use Unity's GUI function

    void OnGUI() {
       if (GUI.Button(new Rect(10, 70, 50, 30), "Exit"))
          Debug.Log("Clicked the exit button");
          Application.Quit();
    }