I am having issues with my pause menu. I have two scripts that make it work. One is the UpdateScript and the other is the PauseMenuScript. Everything is working fine with script except for the audio. I have tried adding a few things but nothing is working. I am sure its an easy fix, but I can't figure it out. I want the background music to stay on, but all other sounds (like CopperActiveLoop) to turn off. Both of the scripts below are added to a camera called PauseMenuCamera.
Since I don't want to post another question, my other issue with the pause menu, is once you click "Resume" the character does a punch since left clicking is the command to punch. Is there something I can add to this code, or the playercontrol code to stop him from punching only when resume is clicked?
UpdateScript:
function Update () {
if(Input.GetKey("p"))
{
Time.timeScale = 0;
var script3 = GetComponent("PauseMenuScript");
script3.enabled = true;
var script4 = GetComponent("HideCursorScript");
script4.enabled = false;
}
}
PauseMenuScript:
var newSkin : GUISkin;
var logoTexture : Texture2D;
function thePauseMenu()
{
GUI.BeginGroup(Rect(Screen.width / 2 - 200, 50, 425, 250));
GUI.Box(Rect(0, 0, 500, 250), "");
GUI.Label(Rect(15, 10, 300, 68), logoTexture);
//pause menu buttons
if(GUI.Button(Rect(80, 20, 250, 70), "Resume")) {
Time.timeScale = 1.0;
var script3 = GetComponent("PauseMenuScript");
script3.enabled = false;
var script4 = GetComponent("HideCursorScript");
script4.enabled = true;
}
if(GUI.Button(Rect(15, 100, 400, 70), "Main Menu")) {
Application.LoadLevel(0);
}
if(GUI.Button(Rect(110, 175, 180, 70), "Quit")) {
Application.Quit();
}
GUI.EndGroup();
}
function OnGUI ()
{
GUI.skin = newSkin;
Screen.showCursor = true;
thePauseMenu();
}
Thanks for the help!