Volumeslider all the way down, but still sounds on re-enter game

Hello

I have created a music and volume slider and hooked them up with playerprefs to store their values. That part works, it always remember where i left the slider.

But even when i turn the sliders all the way down, it works in game mode, but when i exit game and run again, the sliders are all the way down as expected but the sound is on, I have to manually move the slider in order for it to fetch its true values it seems??

Please advice

Cheers

Nothing keeps the slider and your own persistent notion of volume in sync except your own code.

Usually the parts you want when the scene starts are:

  • read the volume setting from preferences, with a default value
  • set the volume in Unity (however you are doing that)
  • set the slider value with this value

When the slider moves (hook the onValueChanged callback), take its value and:

  • set the volume in Unity (however you are doing that)
  • store the value in your preferences