AudioListener.volume listener.volume

Okay I want to turn off all audio at once when the mute button is being pressed.
I found AudioListener.volume that works to adjust volume, but I tried attaching a code with an empty object, it didn’t work.

Then I found out that I could use the listener script on Unify Community to control the audio volume, which it works like a charm! However, the instruction says that I need to use the following variable declaration in a different script, and drag the Game Object containing the Audio Listener component onto the Listener variable. Then I can call " listener.Volume(value); " from other gameobject. I haven’t been able to make it work yet…

var listener : Listener;

I wonder if it is unity iphone or something else, it says that Listener does not denote a valid type.

What should I do? I have been working on this whole day and nothing is working…

The type should be AudioListener rather than Listener.

–Eric

Thanks!! Back to the main question, how do I call the audio mute from my mute button? I tried using AudioListener.volume, but it didn’t work.

AudioListener has a misleadingly-named pause property. This doesn’t actually pause playback, but rather mutes the audio.

Did this change? I figured that’s what it would do, but it actually did pause, when I tested it; I was impressed.

Urh? Sorry, I was going by the docs on this one. I have to admit I’m surprised it actually does that. Good save :wink: