private void SaveToFile() { StringListStruct allEntries = new StringListStruct(); foreach (var entry in logItems.buttons) { allEntries.strings.Add(entry.content.text); } string jsonObject = JsonUtility.ToJson(allEntries); ValidateFile(); //now let's write down everything string dataFilePath = Application.persistentDataPath + "/"; File.WriteAllText(dataFilePath + "TorporUI/" + actName + ".json", jsonObject); _isModified = false; }
private void Populate() { if (actName == "") { throw new Exception("No act specified for the player log to update from"); } ClearNotes(); ValidateFile(); //now let's read everything string dataFilePath = Application.persistentDataPath + "/"; string notesJson = File.ReadAllText(dataFilePath + "TorporUI/" + actName + ".json"); StringListStruct stringStruct = JsonUtility.FromJson <StringListStruct>(notesJson); if (stringStruct != null) { foreach (string entry in stringStruct.strings) { CreateEntry(entry); } } }