I am using NGUI for menu creation. For sound on/off purpose, I am using toggle button which works correctly.
So what next I have to do ? Also this time I searched other posts for my current solution.
If you more information then I am ready to provide.
Exalia
2
You can make your code independent of previous button state
Example :
Button Script :
public GameObject audioSource;
bool soundToggle = true;
OnGUI()
{
soundToggle = !soundToggle;
if(soundToggle)
{
audioSource.SetActive(true);
//audioSource.mute = true;
//audioSource.volume = 1.0f;
}
else
{
audioSource.SetActive(false);
//audioSource.mute = false;
//audioSource.volume = 0.0f;
}
}
When the button is pushed toggle a boolean, set the AudioListener in your scene to inactive when the boolean is false.
http://forum.unity3d.com/threads/74698-Toggle-Sound-On-Off