I am trying to make my own puse script from various tutorials and snippets, it was going ok till i started to add buttons… At first they would appear even when not paused. not they don’t appear at all.
Maybe i am not putting it in the right place? i tried the ONGUI but it kept saying error.
//My First (Pause Menu) Script 4 July, 2013
// I'm sure it is full of errors lol, but it's a start!
// Im using what i am reading in tutorials, plus some code examples..
var paused : boolean = false;
var pausedGUI : GUITexture;
var gameName : String = "Game Paused";
var skin:GUISkin;
var pauseTexture : Texture2D;
var windowRect0 : Rect = Rect (670, 250, 150, 50);
var windowRect1 : Rect = Rect (670, 300, 120, 50);
var windowRect2 : Rect = Rect (670, 350, 120, 50);
var windowRect3 : Rect = Rect (670, 400, 120, 50);
static var backgroundColor : Color;
function Update () {
if(Input.GetKeyDown("p") && paused == false)
{
//IF GAME IS PAUSED
paused = true;
Time.timeScale = 0;
AudioListener.pause = true;
Screen.showCursor = true;
GUI.backgroundColor = Color.blue;
guiTexture.texture = pauseTexture;
//GUISkin.CreateInstance new.skin;
} else if(Input.GetKeyDown("p") && paused == true) {
//IF GAME IS NOT PAUSED
paused = false;
AudioListener.pause = false;
Time.timeScale = 1.0;
Screen.showCursor = false;
}
}
function OnGUI () {
//Make New Windows
if(Input.GetKeyDown("p") && paused == true) {
guiTexture.texture = pauseTexture;
guiText.text = gameName;
GUI.color = Color.green;
windowRect0 = GUI.Window (0, windowRect0, PauseWindow, "Resume Game");
GUI.color = Color.yellow;
windowRect1 = GUI.Window (1, windowRect1, PauseWindow, "Load, Save Game");
GUI.color = Color.yellow;
windowRect2 = GUI.Window (2, windowRect2, PauseWindow, "Load, Save Game");
GUI.color = Color.yellow;
windowRect3 = GUI.Window (3, windowRect3, PauseWindow, "Load, Save Game");
}
}
// Make the contents of the window.
// The value of GUI.color is set to what it was when the window
// was created in the code above.
function PauseWindow (windowID : int) {
if (GUI.Button (Rect (10,20,100,20), "Hello World"))
print ("Got a click in window with color " + GUI.color);
// Make the windows be draggable.
GUI.DragWindow (Rect (0,0,10000,10000));
}
Im trying to get it to appear as:
Game Paused
Button 1
Button 2
Button 3
Button 4
with a gray background image