Search Unity

Application.Quit() still quits the whole app on start

Discussion in 'Scripting' started by Calif96, Apr 24, 2015.

  1. Calif96

    Calif96

    Joined:
    Apr 16, 2015
    Posts:
    21
    I tried returning bool (true or false), tried to get an input, so that if someone presses a button they quit the game...nothing works and I can't seem to get it to work.

    I creten a script which got attached to an empty gameobject which then got dragged into the OnClick under the Exit button.

    Here's the code, just point me in the right direction...thanks.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Quit : MonoBehaviour {
    5.  
    6.     // Use this for initialization
    7.     void Start () {
    8.  
    9.     }
    10.    
    11.     // Update is called once per frame
    12.     void Update () {
    13.         if (Input.GetButton("Fire1")){
    14.        
    15.         Application.Quit();
    16.         }
    17.  
    18.     }
    19. }
    20.  
    Oh and I also tried rearranging but when I click on the button, it doesn't do anything:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Quit : MonoBehaviour {
    5.  
    6.     // Use this for initialization
    7.     void Start () {
    8.         if (Input.GetButton("Fire1")){
    9.            
    10.             Application.Quit();
    11.         }
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update () {
    16.  
    17.        
    18.  
    19.     }
    20. }
    21.  
     
  2. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    I think this only works on the export not in the unity game test.
     
  3. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Read the documentation. It clearly states that Quit does not work in the editor.
     
  4. Calif96

    Calif96

    Joined:
    Apr 16, 2015
    Posts:
    21
    Thanks Stef_Morojna

    And Fluzing how dare you be so damn rude? Do you really think I am that unintelligent? Please, save it to yourself. I have BUILT it and then tested it, but then again, I am sure it is out of your reach as someone who can actually help out wouldn't say such obnoxious answers and provide helpful answers.

    On another note, read the title...
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Dude, chill. @Fluzing was attempting to help by providing a valid answer.

    If you want highly precise, accurate answers, then learn to write a decent question. The following information would be useful.
    • What actually happens?
    • What do you intend to happen?
    • Is this running in the editor or the actual build. What build target (some targets don't allow explicit quitting).
    The actual answer to your problem is simple. But unfortunately your attitude has ticked off one of the most helpful UI teachers. Maybe I'll come back later.
     
    Ryiah and Fluzing like this.
  6. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Actually what are targets that don't allow explicit quitting?
     
    Kiwasi likes this.
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    The web player and webGL builds both ignore the Application.Quit command. I think everything else is good.
     
  8. Calif96

    Calif96

    Joined:
    Apr 16, 2015
    Posts:
    21
    Frankly I'm tired of rudeness on this forum. Being constantly put down because I am not as good a someone else or I don't understand something. I thought that this was a Community Forum, a place where people want to learn and help others.

    I am sick and tired and it has actually put me off from using the Unity Forum...Constant rudeness and obnoxious behavior, everywhere I go, literally.
     
  9. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You don't have to stay. You can make games in Unity perfectly well without engaging in the forums. There are even other engines you can try, who probably have a different culture in their forums. (Then again, this is the internet, so maybe not).

    Alternatively you can make the assumption that everyone here is trying to help, apologise for calling us all rude and obnoxious, and get the answer to your question.

    Best of luck with your future endeavours.
     
  10. Calif96

    Calif96

    Joined:
    Apr 16, 2015
    Posts:
    21
    At the end of the day you're big headed and I will get to where I want nonetheless without your help. Save yourself the trouble with your fancy titles like "one of the most helpful UI teachers".
    Frankly, I do not need this forum to accomplish what I want but without people like me, there wouldn't be no Unity forum, because it's people like me who keep it alive.

    I have tried most Engines and development software out there and I came here to learn Unity, how it works, along with C Sharp. So good luck in life because with this attitude you won't get far. Goodbye
     
  11. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    People get set off when you take a statemenant or simple answer and respond in hostile way. Its not about being put down because you not as smart with a certain topic as others yet. Its your about your rubbish attitude.

    Also @BoredMormon's title of being a decent teacher is a pretty valid one, since I seen him participate in ui threads in a very positive manner since 4.6 was a beta.

    Also along with webgl and webplayer I believe android and iOS targets also don't listen to quit, its mostly PC standalone where it is actually useful. Since most other platforms have there own way of quiting.
     
  12. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Wow, you try to help someone and it turns into a flame war. Good luck man and a heads up: if you have difficulty dealing with people on this forum (which is one of the best out there), you are in for a treat when you try to keep a job in programming.
     
    rabbixt likes this.