I am making a 2D game for Android. Almost completed the game but now I need a pause game option. I added a pause icon on the top right side of the screen. The icon is a GUI texture. What I did so far :
I made a script which will bring up some buttons (which is not working) and attached it to the GUITexture
.This is the script :
#pragma strict
function OnMouseDown() {
Debug.Log("*Pause Menu Opens*");
Time.timeScale = 0;
if (GUI.Button(Rect(10,10,100,50),"Restart"));
Application.LoadLevel(Application.loadedLevel);
if (GUI.Button(Rect(10,60,100,50),"MainMenu"));
Application.LoadLevel("MainMenu");
}
Now the problem stands at the part where the buttons won't show up and the game freezes at the first frame. Please if you can help I would be really thankful.
Edit #1
: I just noticed that when I click "Pause" the game freezes and it takes me to the MainMenu
. That's because I added the GUIButton
which takes you to the main menu. I think the whole script structure is wrong. I also forgot to mention that I am new to scripting/unity.
Thank you.