Search Unity

exit button for windows 8 phone app

Discussion in 'Windows' started by karanvir, Aug 12, 2013.

  1. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    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. :confused:
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    When you press back button on your Windows Phone, it's registered as "Escape" key. So, this should work:

    Code (csharp):
    1. if (Input.GetButton("Escape"))
    2. {
    3.         Application.Quit();
    4. }
     
  3. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    thanks, i will try.
     
  4. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    will it work in unity 3d??
     
  5. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    it's not working:(
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Which part doesn't work? The input doesn't get registered? Or the Application.Quit() doesn't exit the game?
     
  7. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    Application.Quit() doesn't quit the game
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you post your full script?
     
  9. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    no because it's confidential
     
    Last edited: Aug 12, 2013
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I meant only the function where you call Application.Quit(). I have no use for anything else.
     
  11. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    the error is of this type:
    at UnityEngineProxy InternalCalls.Input_Custom_GetKeyString(String name)
     
  12. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    function Update(){


    if (Input.GetButton("Escape"))
    {
    Application.Quit();
    }
    }
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Error? The code doesn't compile? Can you post the full error message?
     
  14. SteAbra

    SteAbra

    Joined:
    Feb 2, 2010
    Posts:
    13
    This must be "escape" and not "Escape" ... BackButton working fine on my HTC8S and Application.Quit() ...
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    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?
     
  16. karanvir

    karanvir

    Joined:
    Aug 12, 2013
    Posts:
    24
    I found the exact coding sir which is :

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


    and it works now.
    Thanks for your support.:D
     
    Aeshian likes this.