I have a problem creating a simple pause menu in my game and this is my first time working with GUI. My problem is when I move over the text in the pause menu its not recognizing it, the text doesn’t turn red and the buttons don’t work. I am using two different scripts I have found on the web, combined and slightly modified them. Does it have anything to do with having to use the “Draw” function? Thanks for reading my question. On a side question for this script when I unpause the game using the Esc key the background music starts over, how do I fix that? Here is the script:
#pragma strict
var pause : boolean = false;
var resumeGUI : GUITexture;
private var allAudioSources : AudioSource[];
resumeGUI.enabled = false;
function Awake()
{
allAudioSources = FindObjectsOfType(AudioSource) as AudioSource[];
}
function PauseAllAudio()
{
for(var audioS : AudioSource in allAudioSources) { audioS.Pause(); }
}
function ResumeAllAudio()
{
for(var audioS : AudioSource in allAudioSources) { audioS.Play(); }
}
function Update()
{
if(Input.GetKeyUp(KeyCode.Escape))
{
if(pause==true)
{
pause = false;
}
else
{
pause = true;
}
if(pause == true)
{
Time.timeScale = 0.0;
resumeGUI.enabled = true;
PauseAllAudio();
}
else
{
Time.timeScale = 1.0;
resumeGUI.enabled = false;
ResumeAllAudio();
}
}
}
var isMainMenu=false;
function OnMouseEnter()
{
//change text color
guiTexture.color = Color.red;
}
function OnMouseExit()
{
//change text color
guiTexture.color = Color.white;
}
function OnMouseUp()
{
//is this quit
if (isMainMenu==true)
{
//load main Menu
Application.LoadLevel("AliensMainMenu");
}
else
{
Time.timeScale = 1.0;
resumeGUI.enabled = false;
ResumeAllAudio();
}
}