I'm making an iOS game with no music, just sfx. I want to toggle it on/off from a main menu's button and from an in-game button. What function will this button have to call?
2 Answers
2Take a look at this answer:
http://answers.unity3d.com/questions/8007/i-need-to-make-a-mute-button-solved
You most like also need to store your audio setting using PlayerPrefs:
http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.html
check this link to see how sounds are played http://answers.unity3d.com/questions/53342/playing-music-while-scenes-change/53372#53372
//attach something like this inside script
function PlayStopMySoundFX(soundFX:boolean)
{
if(soundFX)
{
audio.Play();
}
else
{
audio.Stop();
}
}
//in another script
//call PlayStopMySoundFX via sendmessage
yourAudioGameObject.SendMessage("PlayStopMySoundFX", true, SendMessageOptions.DontRequireReceiver);
//or
yourAudioGameObject.SendMessage("PlayStopMySoundFX", false, SendMessageOptions.DontRequireReceiver);
Thank you Mortennobel!
– schwertfisch