- Home /
Application.Quit() won't exit game?!
Hello, I've little problem with my simple game.
This is code I'm using for menu control #pragma strict
var isIZADJI=false;
function OnMouseEnter()
{
renderer.material.color=Color.red;
}
function OnMouseExit()
{
renderer.material.color=Color.white;
}
function OnMouseUp()
{
if(isIZADJI)
{
Application.Quit();
}
else
{
Kontrola_Zivota.ZIVOTI=3;
Application.LoadLevel(1);
}
}
Reseting level woring but exiting game won't work. It just reload first level?
Are you setting 'isIZADJI' to 'true' anywhere? It will only exit, if this variable is true, so you should print that to the console, to see if it is set correctly.
yep, if the first level is starting, then obviously "isIZADJI" is not set to true, so you're actually reaching LoadLevel(1) every time..
You should be adding some Debug.Log's :
if(isIZADJI)
{
Debug.Log("Quit");
Application.Quit();
}
else
{
Debug.Log("Restart");
$$anonymous$$ontrola_Zivota.ZIVOTI=3;
Application.LoadLevel(1);
}
or some such
Well caught, guys, and great advice about adding Debug.Log output to catch your variable states, very useful stuff.
Ok, I added that lines and debug said this
WHEN I PRES RESTART it prints to console: Restart UnityEngine.Debug:Log(Object) The referenced script on this Behaviour is missing!
WHEN I PRESS QUIT it prints to console: The referenced script on this Behaviour is missing!
Answer by glc · Aug 28, 2012 at 06:40 PM
Ok Ok I managed it.. Code is working perfectly, I just needed to say in Unity3D on what text "isIZADJI" will be true..
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
[Solved] Exit scene OnCollisionEnter not working 2 Answers
What Calls Upon The Game Stopping? 1 Answer
Setting Scroll View Width GUILayout 1 Answer
convert c# to JavaScript Problem 0 Answers