private async Task CreateFile(string fileName) { using (StreamWriter sw = new StreamWriter(fileName)) { Settings = new ImportedSettings(); var output = JsonUtility.ToJson(Settings, true); await sw.WriteLineAsync(output); } }
private async void LoadImportedProperties() { string fileName = "settings.txt"; try { using (StreamReader sr = new StreamReader(fileName)) { string text = await sr.ReadToEndAsync(); Settings = JsonUtility.FromJson <ImportedSettings>(text); } if (!Settings.ValidateSuccess()) { await CreateFile(fileName); } } catch (Exception e) { Debug.Log(e); await CreateFile(fileName); } Debug.Log(Settings.ToString()); }