About Quiting the app

i saw it once and now use it everythere )) instead of just application.quit use this code
// put where all the namespaces are ( “using” keywords in top)
#if UNITY_EDITOR
using UnityEditor;
#endif
// for proper quiting from app if it’s buid and from playmode if in editor
if (Input.GetKey(KeyCode.Escape))
{
#if UNITY_EDITOR
EditorApplication.ExitPlaymode();
#else
Application.Quit();
#endif
}

7 Likes

Pretty cool and something I want to use in the future. I’m assuming the lines prefixed with # are some kind of compiler/interpreter instruction like C++ has.

2 Likes

Privacy & Terms