Togle sound and texture

I’m trying to create a mute button. I’ll click on it the sound will go on off and the texture on it will switch too (like a speaker with a bar on it or no).

I figure out how to toggle the sound but how can I toggle the texture?
If you have a script example it will be great. Thanks!

function OnMouseDown ()
{
playing = !playing; 
if (audio.isPlaying  !playing) audio.Stop();
if (!audio.isPlaying  playing) audio.Play();
}

hello!

Checkout this:

var flagButton : boolean = true;

function OnGUI(){
    if(GUI.Button(Rect(10,10,50,50),yourTexture){
        if(flagButton){
            yourTexture = mute.png
            flagButton = false;
        } else {
            yourTexture = sound.png
            flagButton = true;
        }
    }

}

I haven’t tested that code, so it probably wont work, but it will illustrate you how more or less it works :slight_smile:

Hope it helps you! :wink: