var restart=GUI.Button(Rect(30,145,200,50),“restart”);
if(restart)
{
Application.LoadLevel(1);
}
This is my code snippet. I tried to restart my scene then the game hangs.I had no idea why it behave so,also tried “Application.LoadLevelAdditive(1);”
but no good.

Do anybody have an idea why my game hangs while it restarts?

That is because once you push the button the variable doesnt reset and keeps loading the scene (if your object is set to not get destroyed on load). Maybe use this:

var restart=GUI.Button(Rect(30,145,200,50),"restart");

if(restart)
{
Application.LoadLevel(1);
restart = !restart;
}

I guess this will fix it. Hope it helped!

This will solve your problem. :slight_smile:

if(GUI.Button(Rect(30,145,200,50),"restart"))
{
    Application.LoadLevel(1);
}

hi all,
thanks for your help. At last i figure out my problem. the problem related to STATIC variables. i made static variables as state flags. one of my static variable remains in false state that triggers the PAUSE command. then when the scene restarts the game hangs without a warning.

once again thank you all.