|
I try to make a mute button on my HUD. So I used the code I found here: http://answers.unity3d.com/questions/15307/i-need-to-make-a-mute-button-solved.html According to the above link, I add code below to my OnGUI script: Well, this button works great when it is hit the first time, and it mutes the sound, but it doesn't replay the audio. I think I have to add this to somewhere else too, so it checks it continuously but I don't know where to put it. thanks for your helps in advanced.
(comments are locked)
|
|
You're confusing several things here: If you want to mute all sounds in your game, you can use this:
if (GUI.Button (Rect(1090,0, 110, 110), PlayTex, GUIStyle.none))
{
M_Mute = !M_Mute;
AudioListener.pause = M_Mute;
}
But if you want to pause some specific sound and resume it later, you must place this code in the object owner of the AudioSource you want to stop/resume:
if (GUI.Button (Rect(1090,0, 110, 110), PlayTex, GUIStyle.none))
{
audio.Pause(); // toggles pause on/off
}
NOTE: The rectangle you've specified in GUI.Button has a too high X coordinate, and may not appear in many computers; if you want to align this button to the right side, set the first argument to Screen.width - buttonWidth, like this: I wanted to mute the audios so I used the approach you explained in 2. And thanks for your comment about the button coordinates.
Dec 30 '11 at 01:23 PM
sanamdehghan
(comments are locked)
|
