Mute audiosource

Updated on February 16, 2017 in [A] GUI
Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on Reddit0
7 on February 14, 2017

Hey guys could any of you tell me how to fix my problem ?
I added a button through the new UI system right . I have audio source on main camera . And i would like to add mute function onto the button. The thing is that I tried to add audiosource>stop on button’s OnClick function and that works . But everytime after you die in game the audio turns ON again . I cant figure this one out. Anyone any idea ?

  • Liked by
  • LeonLaci
Reply
2 on February 15, 2017

if you have an AudioSource, there is an option to mute it.

on February 15, 2017

But after application.loadlevel happens then audio in audio source is played again .

Devoted
on February 15, 2017

Is your audio source on an object with DontDestroyOnLoad ?

Show more replies
  • Liked by
Reply
Cancel
0 on February 15, 2017

Create an Audio Mixer, assign it to the output of your Audio Source and mute the mixer with the button.

  • Liked by
Reply
Cancel
0 on February 15, 2017

I am not 100% sure but if you make a static bool for checking audio and pass the value of it on loadlevel, (static values dont change on loadlevel) although i am not 100% sure, then check the bool again on loadlevel to mute the audio.

  • Liked by
Reply
Cancel
0 on February 16, 2017

You could use PlayerPrefs or any sort of serialization, so you can check if the last time the player pressed the button was mute or unmute, serializing this setting allows you to remember the audio state even on game exit.

  • Liked by
Reply
Cancel
0 on February 16, 2017

Thank you guys . I somehow fixed it .

  • Liked by
Reply
Cancel