I want to press the button “exit” button or the “new game” to come out if you really want to go out or want to start a new game.
That leaves a question whether I really want to do that action.
I feel my English is that I use the translator.
I want to press the button “exit” button or the “new game” to come out if you really want to go out or want to start a new game.
That leaves a question whether I really want to do that action.
I feel my English is that I use the translator.
Are you trying to make a GUI with those two buttons?
If that’s the case, for an exit button you could use:
if (GUI.Button(Rect(10,10,50,30),"Click"))
Application.Quit();
And for the New Game button well, are you working with scenes? Here’s a little help about changing scenes from http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html
Hope that helps!
if no button I have it done but what I need is pressing x button as you leave a window that says “want to get out of this game? Yes____NO”
var exit : boolean = false;
var quit : boolean = false;
function OnGUI ()
{
if(!exit && !quit && GUI.Button(Rect(0,0,100,100),"Quit Game"))
{
quit = true;
}
if(quit)
{
GUI.Label(Rect(130,0,200,100),"Would You like to quit the game?");
if(GUI.Button(Rect(120,20,100,100),"Yes"))
{
exit = true;
quit = false;
}
if(GUI.Button(Rect(230,20,100,100),"No"))
{
quit = false;
}
}
if(exit)
{
GUI.Label(Rect(130,0,200,100),"Are you sure?");
if(GUI.Button(Rect(120,30,100,100),"Im Sure"))
{
Application.Quit();
Debug.Log("Quit the game");
}
if(GUI.Button(Rect(230,30,100,100),"No,Wait!"))
{
exit = false;
}
}
}
I’m still new to unity but this works. Any critiques welcome.