So i created a script for my audio. But when i click on my mute/unmute button it goes to sprite off. And when i click it for the second time its set to on whats supossed to happen. (by on or off the sprite chanches) But when i go to a diffrent scene the sprite returns to on while the audio is off <sprite = musicOff.png or musicOn.png file>
So i need a way that the sprite saves to off and gets loaded back to off when i revisit the MainMenu scene
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Manager : MonoBehaviour {
public GameObject soundControlButton;
public Sprite audioOffSprite;
public Sprite audioOnSprite;
//use this for initialization
void start() {
if (AudioListener.pause == true) {
soundControlButton.GetComponent<Image> ().sprite = audioOffSprite;
} else {
soundControlButton.GetComponent<Image> ().sprite = audioOnSprite;
}
}
//Update is called once per frame
void Update () {
}
public void SoundControl(){
if (AudioListener.pause == true){
AudioListener.pause = false;
soundControlButton.GetComponent<Image> ().sprite = audioOnSprite;
} else {
AudioListener.pause = true;
soundControlButton.GetComponent<Image> ().sprite = audioOffSprite;
}
}
}