Hello and thanks for reading it,
After I made a little menger Script with have GUI on him, I got this picture…
using UnityEngine;
using System.Collections;
public class MainMenu : MonoBehaviour {
public static bool IsPause;
public int LabelWidth;
public int ButtonWidth;
private bool WantRestart;
// Use this for initialization
void Start () {
IsPause=false;
}
// Update is called once per frame
void Update () {
if(Input.GetKeyUp(KeyCode.P)||Input.GetKeyUp(KeyCode.Escape))
{
Time.timeScale=1.0f-Time.timeScale;
IsPause=!IsPause;
}
}
void OnGUI(){
if(IsPause)
InPause();
if(WantRestart)
InRestart();
}
void InPause()
{
GUI.Box(new Rect(10,10,Screen.width-20,Screen.height-20),"Pause Menu");
GUI.Label(new Rect(Screen.width/2-LabelWidth/2,Screen.height/4,LabelWidth,30),"The Game is paused");
if(GUI.Button(new Rect(Screen.width/2-ButtonWidth/2,Screen.height/3,ButtonWidth,30),"Continue"))
IsPause=!IsPause;
if(GUI.Button(new Rect(Screen.width/2-ButtonWidth/2,Screen.height/3*1.5f,ButtonWidth,30),"Restart"))
WantRestart=true;
if(GUI.Button(new Rect(Screen.width/2-ButtonWidth/2,Screen.height/3*2,ButtonWidth,30),"exit"))
Application.LoadLevel(0);
}
void InRestart(){
GUI.Box(new Rect(Screen.width/2-ButtonWidth*1.5f,Screen.height/2-ButtonWidth*1.5f,ButtonWidth*3,100),"Are you sure?");
if(GUI.Button(new Rect(Screen.width/2-ButtonWidth,Screen.height/2-25,ButtonWidth,30),"no"))
WantRestart=false;
if(GUI.Button(new Rect(Screen.width/2+ButtonWidth*0.5f,Screen.height/2-25,ButtonWidth,30),"yes"))
Application.LoadLevel(1);
}
}
I wish I could do it more transparent…
please help me