Reputation:
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
Reputation: 13297
Application.Quit
won't work in the editor:
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
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