private void Start() { // on first startup if (!PlayerPrefs.HasKey("volumeSetting")) { PlayerPrefs.SetFloat("volumeSetting", 1.0f); } // set slider values and visuals to saved values (which then sets saved values again but whatever) volumeSlider.SetValue((int)(PlayerPrefs.GetFloat("volumeSetting") * volumeSlider.maxValue)); extraTimeSlider.SetValue((int)(PlayerPrefs.GetFloat("addedTimeSetting") * extraTimeSlider.maxValue)); }
void Start() { float tmp; gameConfig.mixer.GetFloat("MasterVolume", out tmp); masterVolume.SetValue(tmp); gameConfig.mixer.GetFloat("MusicVolume", out tmp); musicVolume.SetValue(tmp); gameConfig.mixer.GetFloat("SFXVolume", out tmp); sfxVolume.SetValue(tmp); masterVolume.GetOnValueChanged().AddListener(value => ApplySettings()); musicVolume.GetOnValueChanged().AddListener(value => ApplySettings()); sfxVolume.GetOnValueChanged().AddListener(value => ApplySettings()); }