- Home /
New Game & Quit Game in 1 script
Hi guys, I am working on my Main Menu for my game, And I am making a script to Start a new game and quit game. But instead of making 2 script I have decided to put it all in one.
var newGame : boolean;
function OnMouseUp(){
if(newGame)
newGame=true;
Application.LoadLevel("Level_1_Awake");
}else{
Application.Quit();
}
I have not done this before thus I can't get it to work. I want it to be a "Boolean" which I believe would make it easier, So if I tick a box then the game would know whether to Quit the application or Load level 1.
sorry about the script being messy. Thank you in advance! -Izzy
Answer by save · Sep 05, 2012 at 03:34 PM
This should work as long as you have a collider on the object:
var newGame : boolean;
function OnMouseUp () {
if (newGame) {
Application.LoadLevel("Level_1_Awake");
} else {
Application.Quit();
}
Thanks mate works perfectly :D Final Code:
var newGame : boolean;
function On$$anonymous$$ouseUp () { if (newGame) { Application.LoadLevel("Level_1_Awake"); } else { Application.Quit(); } }
Your answer
![](https://koobas.hobune.stream/wayback/20220613080648im_/https://answers.unity.com/themes/thub/images/avi.jpg)