The question is answered, right answer was accepted
Need help with Mute Button
How to make the mute button remember witch image it has when i click on it.Because now when i click on it changes from unmuted img to muted and the music goes from unmuted to muted, but when i change scenes it goes back to unmuted img but the music is muted and when i pres the button stays unmuted and the music becomes unmuted. I m a beginner in c# here is the script
public class audiomute : MonoBehaviour {
public GameObject mutetxt;
public GameObject unmutetxt;
public void OnMOuseDown()
{
if (AudioListener.pause != true)
{
AudioListener.pause = true;
mutetxt.SetActive(true);
unmutetxt.SetActive(false);
}
else {
AudioListener.pause = false;
mutetxt.SetActive(false);
unmutetxt.SetActive(true);
}
}
}
Answer by MakinStuffLookGood · Nov 12, 2015 at 07:37 PM
Simplest solution would be to just have it set the image in it's Awake method based on the state of the static variable AudioListener.pause.
void Awake()
{
mutetxt.SetActive(!AudioListener.pause);
unmutetct.SetActive(AudioListener.pause);
}
Note: Muting a pausing aren't really the same, have you considered using AudioListener.volume = 0
instead of pausing the audio?
Follow this Question
Related Questions
How to use one button to play different audio for different Targets? 0 Answers
Change color for disabled button 1 Answer
Coroutine and SetFloat not working as expected 0 Answers
Next and Back Button? 0 Answers
How to stop and re-start audio? 1 Answer