void Awake() { //Set(PlayerPrefsHelper.Read(key, defaultValue)); // Don't show "that" value = PlayerPrefsHelper.Read(key, defaultValue); Cursor.SetCursor(cursors[value], Vector2.zero, CursorMode.Auto); }
// Initialize in Awake() instead of Start() since menus' Late Disable script // can unpredictably prevent Start() from running. // P.S. // This is no longer a concern as settings initialize independently from the menus. // Each settings script does the following on initialization: // - Read a value from PlayerPrefs // - Optionally apply the settings to the game // (dim/brighten the screen, adjust the volume levels, adjust the resolution) // - Optionally apply the changes to the UI elements if there are any attached // (setting the sliders and toggles to the correct state) protected void _Awake() { value = PlayerPrefsHelper.Read(key, defaultValue); Apply(); if (toggleGroup != null && toggles.Length > 0) { ApplyUI(); } }
void Awake() { // Read float value = PlayerPrefsHelper.Read( SettingsConst.BRIGHTNESS_KEY, SettingsConst.BRIGHTNESS_DEFAULT); // Apply Set(value); // ApplyUI if (brightness != null) { brightness.value = value; } // Unlike toggles, sliders don't fire the event if the value doesn't change. }
void Awake() { // Read float valueMaster = PlayerPrefsHelper.Read( SettingsConst.VOLUME_MASTER_KEY, SettingsConst.VOLUME_MASTER_DEFAULT); float valueMusic = PlayerPrefsHelper.Read( SettingsConst.VOLUME_MUSIC_KEY, SettingsConst.VOLUME_MUSIC_DEFAULT); float valueSounds = PlayerPrefsHelper.Read( SettingsConst.VOLUME_SOUNDS_KEY, SettingsConst.VOLUME_SOUNDS_DEFAULT); float valueVoice = PlayerPrefsHelper.Read( SettingsConst.VOLUME_VOICE_KEY, SettingsConst.VOLUME_VOICE_DEFAULT); // Apply SetMaster(valueMaster); SetMusic(valueMusic); SetSounds(valueSounds); SetVoice(valueVoice); // Apply UI if (master != null) { master.value = valueMaster; } if (music != null) { music.value = valueMusic; } if (sounds != null) { sounds.value = valueSounds; } if (voice != null) { voice.value = valueVoice; } }