FoKycHuK
FoKycHuK

Reputation: 309

How can i stop unity from script?

I need to close unity from my scripts. As if I clicked on the stop-button in GUI. Can i do this directly from code, or not? I know, how i can close a scene, but need to close all processes.

Upvotes: 0

Views: 7569

Answers (1)

David
David

Reputation: 16287

Application.Quit(); // Quit the deployed game/App

Or as Chris commented, use below code to quit Unity Editor:

EditorApplication.Exit(0); 

Or you wish to pause the player:

EditorApplication.isPaused = true;

Or consider using boolean property:

EditorApplication.isPlaying = false;

Or you are talking about this? Then try:

Debug.Break();  //stop running at run-time,

See online documentation here and here.

Choose whichever that matches your intents.

Upvotes: 13

Related Questions