user285372
user285372

Reputation:

Application.Quit not quitting the running app

I have the following code that shows me the time counting in the console, but it would not quit the program when it reaches 10 seconds. Am I missing something?

void Update ()
{
    Debug.Log ( Time.timeSinceLevelLoad );

    if ( Time.timeSinceLevelLoad > 10 )
        Application.Quit();
}

Upvotes: 0

Views: 3551

Answers (2)

Max Yankov
Max Yankov

Reputation: 13297

Application.Quit won't work in the editor:

Quit is ignored in the editor or the web player.

If you want to test the behavior of quitting the game, just build it. If you want to quit the editor, use EditorApplication.Exit from the editor script.

Upvotes: 2

MethodMan
MethodMan

Reputation: 18843

if this method is within a Console App change the method signature below from void Update() to private static void Update()

void Update()
{
    Debug.Log ( Time.timeSinceLevelLoad );
    if ( Time.timeSinceLevelLoad > 10 )
    {
         System.Environment.Exit(0);
    }
}

Upvotes: -1

Related Questions