- Home /
Creating a Sound setting and saving it.
What I need for my game is a functional settings menu. But I'm having trouble with the volume setting specifically, it works like intended, but I can't get the "saving" feature to work aka using playerprefs.
private void Start()
{
volSlider.value = PlayerPrefs.GetFloat("MVolume", 0);
volMixer.SetFloat("volume", PlayerPrefs.GetFloat("MVolume"));
}
public void changeVol(float volume)
{
volume = Mathf.Log10(volume) * 20;
PlayerPrefs.SetFloat("MVolume", volume);
volMixer.SetFloat("volume", PlayerPrefs.GetFloat("MVolume"));
}
Little note. The playerpref system works, when I don't use the mathf.log10 formula and just leave the float volume as it is, but the problem with that is that the actual slider works pretty weird, because the sound is all the way muted already at 50% of the slider. Therefore volume = Mathf.Log10(volume) * 20; , but I can't get the playerpref system working properly. Every time the game is started the slider value defaults to the lowest (0.0001). Thanks for any help in advance!
Your answer
Follow this Question
Related Questions
Is it possible to modify the DopplerFactor in Edit->ProjectSettings->Audio on-the-fly per scene? 2 Answers
Audio Settings Menu 2 Answers
Audio Loops? 1 Answer
fmod 3d listener only updates once at start of script 0 Answers
Calling sound once in update 1 Answer