x


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?

more ▼

asked Apr 19 '11 at 05:53 PM

schwertfisch gravatar image

schwertfisch
370 53 57 68

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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

more ▼

answered Apr 19 '11 at 06:06 PM

Mortennobel gravatar image

Mortennobel
1.8k 10 15 34

Thank you Mortennobel!

Apr 21 '11 at 07:17 AM schwertfisch
(comments are locked)
10|3000 characters needed characters left

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);
more ▼

answered Apr 19 '11 at 06:08 PM

synapsemassage gravatar image

synapsemassage
426 2 5 16

Thank you :)

Apr 19 '11 at 06:13 PM schwertfisch
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1958
x786
x523
x161
x10

asked: Apr 19 '11 at 05:53 PM

Seen: 1316 times

Last Updated: Apr 19 '11 at 05:53 PM