I wrote this code to reload saved settings for sliders at start, if there is no save settings, then it reloads default values. Then there is also a reset settings function, which I assigned to a button in the UI.
I call LoadSettings() Function on OnEnable() function.
The weird thing is, the mouse sensitivity part is working perfectly, but the music and master volume part does not work. When I press reset button for the first time, the mouse sens part works perfectly again, but the rest doesn`t work. However, if I press reset button a second time, then everything works fine. What could be causing this? Thanks.
You are using different keys: GetFloat("MasterVolume") SetFloat("Master Volume", masterVolume.value)
Put string in a static/const variable and use it to avoid such typos.
One is for audio mixer, the other for playerprefs. OnSliderChange function which is not up there, playerprefs sets āMasterVolumeā key. I checked spellings many times, problem is not there unfortunately. But you re right I should have used more clear strings.
Im not sure about how to use debugger exactly but Ill try to learn that thank you.
I didn`t check if the player reference is null (in main menu it is null), I just added this. Now music and master audio sliders reloads their saved or default values, but audio mixer values does not change at start until I press reset or change sliders. I used debug.log after each else statement to see if code keeps going and code does not stop anywhere.
If you are sure that the parameter names are correct in PlayerPrefs.GetFloat/PlayerPrefs.SetFloat (which is not in your code) then obviously it is connected to the mixer āfeatureā.
Values cannot be changed in Awake/OnEnable. Change it in Start or do delays.