This is how it looks like opened from the assets folder (on the left), and during gameplay (on the right).
This is the script:
using UnityEngine;
using System.Collections;
public class GameMenu : MonoBehaviour {
private bool paused = false;
private int buttonHeight = 70;
private int buttonWidth = 70;
private int restartWidth = 70;
private GUIContent content = new GUIContent();
public Texture2D image, hover, active;
void Awake(){
content.image = image;
}
void Start () {
Time.timeScale = 1.0f;
}
void OnGUI(){
GUI.skin.button.normal.background = image;
GUI.skin.button.hover.background = hover;
GUI.skin.button.active.background = active;
if (GUI.Button(new Rect(Screen.width - 100, Screen.height - 100, buttonWidth, buttonHeight), content)) {
if(!paused) {
togglePause ();
} else {
StartCoroutine(myCoroutine());
}
paused = !paused;
}
if (paused) {
if (GUI.Button (new Rect (Screen.width / 3 - restartWidth, Screen.height / 2 - buttonHeight, restartWidth,
buttonHeight), "Restart")) {
togglePause();
Application.LoadLevel ("GameScene");
}
if (GUI.Button (new Rect (1 * Screen.width / 2 - restartWidth/2, Screen.height / 2 - buttonHeight, restartWidth,
buttonHeight), "Resume")) {
paused = !paused;
StartCoroutine(myCoroutine());
}
if (GUI.Button (new Rect (2 * Screen.width/3, Screen.height / 2 - buttonHeight, restartWidth,
buttonHeight), "Quit")) {
togglePause();
Application.LoadLevel ("MenuScene");
}
}
}
IEnumerator myCoroutine(){
Time.timeScale = 0.001f;
yield return new WaitForSeconds (3f * Time.timeScale);
Time.timeScale = 1.0f;
}
void togglePause()
{
if(Time.timeScale == 0f)
{
Time.timeScale = 1f;
}
else
{
Time.timeScale = 0f;
}
}
}