sorry i’m new to programming. I found a script online and inserted in my game object. But when i press play and click mute it does not work. but on the left side there is a new button with test sound on and off. when i click that it works. how can i use my existing icon to turn sound on and off. Here is the script
var muted = false;
function OnGUI(){
if(GUI.Button(new Rect(40, 40, 100, 50), “Sound On/Off”))
{
if(muted == false){
AudioListener.volume = 0;
muted = true;
}
else{
AudioListener.volume = 1;
muted = false;
}
}
}
here is the icon script. how can i set it so the sound is off and on. Thanks
//Audio Icon Triggerer
private function AuidoTriggerer(audioButton : Material)
{
//If the shop is showed, return to the caller
if (!shopHidden)
return;
//If the audio enabled
if (audioEnabled)
{
//Disable it
audioEnabled = false;
audioButton.mainTexture = menuTextures[3];
}
//Else it is disabled
else
{
//Enable it
audioButton.mainTexture = menuTextures[2];
audioEnabled = true;
}
}
added this to the script and it works perfect.
AudioListener.pause = true;
AudioListener.pause = false;