Save Audio Mixer Values

I’m trying to save my audio mixer values via PlayerPrefs, but it isn’t working. Please help!

using UnityEngine;
using UnityEngine.Audio;

public class OptionsMenu : MonoBehaviour {

    public AudioMixer mixer;

    public void SetVolume(float volume)
    {
        mixer.SetFloat("Volume", volume);
    }

    public void OnEnable()
    {
        SetVolume(PlayerPrefs.GetFloat("Volume", 0));
    }

    public void OnDisable()
    {
        float Volume = 0f;

        mixer.GetFloat("Volume", out Volume);

        PlayerPrefs.SetFloat("Volume", Volume);
        PlayerPrefs.Save();
    }




}

OnEnable is called before Awake and setting values before Start doesn’t work with the AudioMixer. I’m not sure if its a bug or not but it only works setting it in Start or after.

1 Like

Thanks!