/** * <summary> * Loads the save from a file to a <see cref="SettingSave"/> object via XML decoding * </summary> */ public static SettingSave LoadSave() // TODO Change to JSON { SettingSave save; // If the directory doesnt exist, create it if (!Directory.Exists(Application.persistentDataPath + "/settings")) { Directory.CreateDirectory(Application.persistentDataPath + "/settings"); } // Read from file, handle nonexistent file cases if (File.Exists(Application.persistentDataPath + "/settings/settings.xml")) { using (FileStream fs = new FileStream(Application.persistentDataPath + "/settings/settings.xml", FileMode.Open)) { XmlSerializer serializer = new XmlSerializer(typeof(SettingSave)); save = (SettingSave)serializer.Deserialize(fs); } } else { save = new SettingSave(); } return(save); }
void Awake() { DontDestroyOnLoad(this); saveFileCache = new SaveFileInfo(); settingFile = new SettingSave(); settingFilePath = Application.dataPath + "/Resources/Setting.json"; LoadSettingFile(); }
/** * <summary> * Load a save from the file * </summary> */ public void LoadSave() { save = SettingSave.LoadSave(); brightnessSlider.value = save.brightness; led_countInput.text = save.led_count.ToString(); autosaveToggle.isOn = save.autosave; brightnessliveupdatesToggle.isOn = save.brightnessLiveUpdates; }
/** * <summary> * Saves the supplied save to a file via XML encoding * </summary> */ public static void Save(SettingSave save) // TODO Change to JSON { if (!Directory.Exists(Application.persistentDataPath + "/settings")) { Directory.CreateDirectory(Application.persistentDataPath + "/settings"); } XmlSerializer serializer = new XmlSerializer(typeof(SettingSave)); TextWriter writer = new StreamWriter(Application.persistentDataPath + "/settings/settings.xml"); serializer.Serialize(writer, save); writer.Close(); }
void LoadSettingFile() { if (!File.Exists(settingFilePath)) { SaveSettingFile(); // create default setting file if not exists } StreamReader sr = new StreamReader(settingFilePath); string json = sr.ReadToEnd(); if (json.Length > 0) { settingFile = JsonUtility.FromJson <SettingSave>(json); } ApplySetting(); }
partial void SubmitButtonClicked(NSObject sender) { settingIndex = rootViewController.settingIndex; planetIndex = (int)RingsCombo.IndexOfSelectedItem; settings[settingIndex].dispAspectPlanet[planetIndex][CommonData.ZODIAC_NUMBER_SUN] = dispAspectPlanetSun.State == NSCellStateValue.On ? true : false; settings[settingIndex].dispAspectPlanet[planetIndex][CommonData.ZODIAC_NUMBER_MOON] = dispAspectPlanetMoon.State == NSCellStateValue.On ? true : false; if (settingIndex == CommonInstance.getInstance().currentSettingIndex) { CommonInstance.getInstance().currentSetting.dispAspectPlanet[planetIndex][CommonData.ZODIAC_NUMBER_SUN] = dispAspectPlanetSun.State == NSCellStateValue.On ? true : false; CommonInstance.getInstance().currentSetting.dispAspectPlanet[planetIndex][CommonData.ZODIAC_NUMBER_MOON] = dispAspectPlanetMoon.State == NSCellStateValue.On ? true : false; } SettingSave.SaveXml(settings); DismissViewController(this); }
// Start is called once before the first frame void Start() { // Load Settings from Storage save = SettingSave.LoadSave(); // Load Commands from Storage commands = Parser.Parse(PlayerPrefs.GetString("list", "base")); foreach (PartCommandList cmd in commands.lists) { cmd.listObject = Instantiate(partCommandPrefab, commandsObject.transform); foreach (Command cmdd in cmd.list) { cmdd.commandObject = Instantiate(commandPrefab, cmd.listObject.transform); cmdd.Init(); } } // Init important Object attributes Command.networkObject = this.gameObject; CommandList.networkObject = this.gameObject; settingsObject.SetActive(false); CheckLists(); }
// Start is called before the first frame update void Start() { // Load the setting save if there is any save = new SettingSave(); LoadSave(); }
/** * <summary> * Save the current save to a file * </summary> */ public void Save() { SettingSave.Save(save); }
partial void SubmitButtonClicked(NSObject sender) { SettingSave.SaveXml(settings); DismissViewController(this); }