Unity code control shutdown program

When the application released by Unity needs to close the code control, it only needs to call the following method: Application.Quit();

And when we are in the editor state, we cannot close it using the above method.

In the editor state, you need to use the following method to exit the running state:

UnityEditor.EditorApplication.isPlaying=false;

So when we want to close the program in the editor and publishing application, we can use the following method:

public void Quitgame()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}

Guess you like

Origin blog.csdn.net/mr_five55/article/details/130997133