public void SyncSettingsWithDisk(Action done) { DynamicSettings dynamicSettings = null; var configFilePath = Path.Combine(Application.persistentDataPath, ConfigFile); if (File.Exists(configFilePath)) { File.ReadAllText(configFilePath); try { //using (FileStream stream = new FileStream(configFilePath, FileMode.Create, FileAccess.Write)) //{ // Serializer.Serialize(stream, dynamicSettings); //} using (FileStream stream = new FileStream(configFilePath, FileMode.Open, FileAccess.Read)) { dynamicSettings = Serializer.Deserialize <DynamicSettings>(stream); } dynamicSettings.Load(); done?.Invoke(); return; } catch (Exception) { } } dynamicSettings = new DynamicSettings(); dynamicSettings.Download(); done?.Invoke(); }
private void Awake() { m_experienceMachine = IOCCore.Resolve <IExperienceMachine>(); m_uiEngine = IOCCore.Resolve <IUIEngine>(); DynamicSettings dynamicSettings = null; var configFilePath = Path.Combine(Application.persistentDataPath, ConfigFile); if (File.Exists(configFilePath)) { File.ReadAllText(configFilePath); try { //using (FileStream stream = new FileStream(configFilePath, FileMode.Create, FileAccess.Write)) //{ // Serializer.Serialize(stream, dynamicSettings); //} using (FileStream stream = new FileStream(configFilePath, FileMode.Open, FileAccess.Read)) { dynamicSettings = Serializer.Deserialize <DynamicSettings>(stream); } dynamicSettings.Load(); return; } catch (Exception) { } } dynamicSettings = new DynamicSettings(); dynamicSettings.Download(); using (FileStream stream = new FileStream(configFilePath, FileMode.Create, FileAccess.Write)) { Serializer.Serialize(stream, dynamicSettings); } }