- Home /
Pause Menu Problems
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!
Answer by Justin Warner · Apr 08, 2011 at 12:21 AM
Disable the "Punching" script until the resume button is pushed, in which, enable it...
I don't know anything about sounds... So I can't help you there... This is why you separate questions XD.
Can you just get the sounds, and pause them? http://unity3d.com/support/documentation/ScriptReference/AudioSource.Pause.html
Or can you just turn the volume down a lot of certain sounds? http://unity3d.com/support/documentation/ScriptReference/AudioSource-volume.html
I don't know though.
I tried to disable punching but it is not working. I don't know if I got the code wrong or if it is not that simple. While the game is paused, you can not punch. However, when you left click resume (thus un-pausing the game) the character punches. Should disableing punching fix this and I just got the code wrong, or is there something else that needs to be done?
Answer by zmar0519 · Apr 08, 2011 at 01:02 AM
in refrence to your audio, you may have to manually stop all behaviours, since you are using time.timescale. also, see the MainManu.js in the bootcamp demo. its big and it's long, but it somehow uses audio and the timescale together.