Mute Button

Hi there, i want to make a mute button for mobile devices but i am having trouble.
I made the script below but the problem is when i change the scene and than turn back to scene i muted, it doesnt save it as muted. And i want to make all scenes mutes when it is used. So what is the best way to do it?

var spriteImageON : Sprite;
var spriteImageOFF : Sprite;


function OnMouseUp()
{

if(audio.mute)
				{
				audio.mute = false;
				
				}
			else{
				audio.mute = true;
			
				}
 }







function Update()
{

 if (audio.mute){

	GetComponent(SpriteRenderer).sprite = spriteImageOFF;
	}
	else{
		GetComponent(SpriteRenderer).sprite = spriteImageON;

		}
		}

You could make the mute code part of a gameobject that does not get deleted when you changes scenes.

Using the .audio access the AudioSource component of the gameObject your script is on. So muting this component will only mute the sound attached to this gameObject.

I suggest you to use AudioListener.volume. Unity can only have one AudioListener active at the same time in a scene. The AudioListener receive input from all audioSource in the scene and output them through your speakers. So muting this will mute all sounds.

AudioListener.volume = 0;

Also since volume is a static variable, all AudioListener share this variable. So reducing volume to 0 will set volume of ALL AudioListener to 0.