exit button for windows 8 phone app

I am developing a game for nokia lumia 920. the work is all over, however, i m not able to exit this game by pressing back button. Suggest me any function in java script for this problem so that i can able to exit it when I will press the back button. :face_with_spiral_eyes:

When you press back button on your Windows Phone, it's registered as "Escape" key. So, this should work:

if (Input.GetButton("Escape"))
{
        Application.Quit();
}

thanks, i will try.

will it work in unity 3d??

it's not working:(

Which part doesn't work? The input doesn't get registered? Or the Application.Quit() doesn't exit the game?

Application.Quit() doesn't quit the game

Can you post your full script?

no because it's confidential

I meant only the function where you call Application.Quit(). I have no use for anything else.

the error is of this type:
at UnityEngineProxy InternalCalls.Input_Custom_GetKeyString(String name)

function Update(){

if (Input.GetButton("Escape"))
{
Application.Quit();
}
}

Error? The code doesn't compile? Can you post the full error message?

This must be "escape" and not "Escape" ... BackButton working fine on my HTC8S and Application.Quit() ...

It depends on how you defined escape key in project input settings.

@OP: You didn't forget to add that to input settings, did you?

I found the exact coding sir which is :

if (Input.GetKeyDown(KeyCode.Escape))
{
Application.Quit();
}

and it works now.
Thanks for your support.:smile:

1 Like