- Home /
Toggle SOUND from main menu and in-game (iOS)
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?
Answer by Mortennobel · Apr 19, 2011 at 06:06 PM
Take 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
Answer by synapsemassage · Apr 19, 2011 at 06:08 PM
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);