i have wrote a script to mute it but it doesn’t work here is that script
function Update() {
if(Input.GetKeyDown("1")) {
if(audio.mute)
audio.mute = false;
else
audio.mute = true;
}
}
and i need it to unmute when the same button is pressed again. any ideas?
thanks
2 Answers
2
khenkel
2
Use this:
function Update()
{
if(Input.GetKeyDown(KeyCode.Alpha1))
{
audio.mute = !audio.mute;
}
}
It didn’t recognize your “1” string. Also the muting is more clean now.
Though your question is not very clear …But still if you need make a toggle sound button then you need to do following :
- get a reference to audiosource
- Save toggle state of your button (for eg. PlayerPref Script will do this saving stuff).
if you dont want to maintain state after the game/app is quit …make use of static for saving states…
thanks it worked great
– bobin115