Volume slider is not saved in edge cases

At 8:20min in the video Ben spots a bug when Slider set to 100% does not save.

This bug is really easy to fix - in PlayerPrefsManager method SetMasterVolume we check if volume is in range between 0 and 1 - otherwise we log an error.

if statement there should include 1 and 0 as correct values but instead it exclude them (>= and <= instead just > and <).

Correct if statement looks like this:

if (volume >= 0f && volume <= 1f) {
    PlayerPrefs.SetFloat (MASTER_VOLUME_KEY, volume);
}

Now we can save also max volume (100%) and min volume (0%)

Thanks to Bartek for the suggestion.

2 Likes

Privacy & Terms