I’m just trying to make a simple front end/HUD and can’t work out the command to make a button quit the game.
Can anyone help me out?
Thanks
I’m just trying to make a simple front end/HUD and can’t work out the command to make a button quit the game.
Can anyone help me out?
Thanks
Hi, welcome to the forum!
You can use GUI.Button to display the button and Application.Quit to make the game quit:-
function OnGUI() {
if (GUI.Button(quitButtonRect, "Quit")) {
Application.Quit();
}
}
thanks!
I am an absolute beginner and I want to do the same thing but can not understand what you put above.
that guys answer is for js not c#
For Unity 5.x
You will need to:
<MyClass.cs>
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MyClass : MonoBehaviour
{
void Start() {}
void Update() {}
public void Quit()
{
Application.Quit();
}
}
thanks Orami works great
Yes, thank you Orami, very simple and very easy to follow.