Unity3d 4.6 UI - Toggle Sound

Hello,
I am using Unity3d 4.6 UI which include the GUI for toggle the Sound. How could I turn off/on the sound using C#.

I appreciate your help,
Aprial

You can disable with “barbarian” code:

    int Count;
    int Leght;

    void Start()
    {
        AudioSettings.GetDSPBufferSize(out Leght,out Count);
    }
    public void ChangeSound(bool Boolean)
    {
        if (Boolean)
        {
            AudioSettings.SetDSPBufferSize(0, 0);
        }
        else
        {
            AudioSettings.SetDSPBufferSize(Leght, Count);
        }
    }

Add ChangeSound() on OnValueChanged(Boolean) on your toggle.

Note: That cause small lag and stop the music, when you re-on.

Thanks TSnake.! Do you know how to contrtrol the volume? Thank you for your help, Aprial.