- Home /
How do you save the Audio Mixer once changed?
Basically I want to save the audio mixer dB numbers once you change it using the slider in the settings page of my game, so when you leave and rejoin the game, the volume will stay the same as to what the the player set the volume to. I've tried quite a few types of code but id didn't work for me. This is the code I have set for my settings script:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Audio; using UnityEngine.UI;
public class SettingsScript : MonoBehaviour { public AudioMixer audioMixer; public Slider slider; public float sliderValue;
public void Start()
{
slider.value = PlayerPrefs.GetFloat("save", sliderValue);
}
public void SetVolume(float volume)
{
audioMixer.SetFloat("volume", volume);
}
public void ChangeSlider(float value)
{
sliderValue = value;
PlayerPrefs.SetFloat("save", sliderValue);
}
}
If you need any other lines of code or names of some sort, feel free to ask!
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Built project, now scripts are missing. 2 Answers
How to fix: !CreateDirectoryRecursive(fullpath) 6 Answers
Initialising List array for use in a custom Editor 1 Answer
Multiple Cars not working 1 Answer