Sound button, works but not completely.

Hi, I added to my game the sound on and off, everything works fine, the only problem is that the game doesn’t remember for a scene to another to set true the volumeOff button.
Here there is the script :

 public void VolumeOn()
    {
        AudioListener.pause = !AudioListener.pause;
        if (AudioListener.pause == false)
        {
            volumeButtonOn.gameObject.SetActive(true);
            volumeButtonOff.gameObject.SetActive(false);

        }
        else if (AudioListener.pause == true)
        {
            volumeButtonOff.gameObject.SetActive(true);
            volumeButtonOn.gameObject.SetActive(false);
        }

have you some ideas? thank you!

You can write the on/off value to the PlayerPrefs mechanism. Since you can’t store a bool value, here is the workaround, contained in a post from 2008 (timeless!):

https://forum.unity.com/threads/playerprefs-setbool-and-playerprefs-getbool.12795/