I have a slider that controls my music volume. It works fine, but if you return to the options menu after going to another scene the slider is at max even though the actual volume is whatever you set it to. Is there a way to update the slider? Here is my code.
using UnityEngine;
using UnityEngine.Audio;
public class OptionsMenu : MonoBehaviour {
public AudioMixer mixer;
public void SetVolume(float volume)
{
mixer.SetFloat("Volume", volume);
}
public void Start()
{
SetVolume(PlayerPrefs.GetFloat("Volume", 0));
}
public void OnDisable()
{
float Volume = 0f;
mixer.GetFloat("Volume", out Volume);
PlayerPrefs.SetFloat("Volume", Volume);
PlayerPrefs.Save();
}
}