/// <summary> /// Saves the option settings. /// </summary> public void SaveOptionSettings() { // Create a new State_Data. Options_Settings GameOptions = new Options_Settings(); // Save the information. GameOptions.SFXToggle = sfxToggle.isOn; GameOptions.SFXVolume = sfxSlider.value; GameOptions.MusicVolume = musicSlider.value; GameOptions.MusicToggle = musicToggle.isOn; GameOptions.UIOneScaling = uiScaleOne; GameOptions.UITwoScaling = uiScaleTwo; GameOptions.UIThreeScaling = uiScaleThree; // Turn the data into Json data. string optionsToJson = JsonUtility.ToJson(GameOptions); // Store the data. PlayerPrefs.SetString("Options", optionsToJson); }
/// <summary> /// Since these are global settings across the board and apply to every scene we assign these here. /// You may notice I do not assign anything with the UI settings because it is handled in the ScalePanelCheck /// functions as that checks for the existance of the UI and assigns the scaling before it is displayed to the user. /// </summary> void SetOptionsSettings(Options_Settings GameOptions) { // Set the music volume and toggle. musicSlider.value = GameOptions.MusicVolume; musicToggle.isOn = GameOptions.MusicToggle; Grid_Helper.soundManager.ChangeMusicVolume(musicSlider.value); Grid_Helper.soundManager.MuteUnMuteBGMusic(musicToggle.isOn); // Set the SFX volume and toggle. sfxSlider.value = GameOptions.SFXVolume; sfxToggle.isOn = GameOptions.SFXToggle; Grid_Helper.soundManager.ChangeSFXVolume(sfxSlider.value); Grid_Helper.soundManager.MuteUnMuteSound(sfxToggle.isOn); // Set the scaling of the panels. uiScaleOne = GameOptions.UIOneScaling; uiScaleTwo = GameOptions.UITwoScaling; uiScaleThree = GameOptions.UIThreeScaling; ScalePanelOneCheck(); ScalePanelTwoCheck(); ScalePanelThreeCheck(); }
/// <summary> /// Loads the options settings. /// </summary> public void LoadOptionsSettings() { // Load the json data. string optionsJson = PlayerPrefs.GetString("Options"); // Load the data structure. Options_Settings GameOptions = new Options_Settings(); // IF there is nothing in this string, // ELSE there is stuff in this string. if (String.IsNullOrEmpty(optionsJson)) { // Load the Defaults. GameOptions.Default(); } else { // Load the saved Json data to our class data. GameOptions = JsonUtility.FromJson <Options_Settings> (optionsJson); } // Set the options. SetOptionsSettings(GameOptions); }