How do you make this button close the game?
If posoble, please give me a script that will work.
I’m sure this information can already be found via a google search, nonetheless, you can put a component on the same game object as the button, and hook up its UnityEvent to the right method.
The code is otherwise pretty simple:
using UnityEngine;
public class QuitGameComponent : MonoBehaviour
{
public void QuitGame()
{
if (Application.isEditor)
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.ExitPlaymode();
#endif
}
else
{
Application.Quit();
}
}
}
Thank you for the code!