public RootHistory(Element element) { bool flg = false; string filepath = Application.persistentDataPath + "/history.json"; if (!File.Exists(filepath)) { RootHistory root = new RootHistory(); string str = JsonUtility.ToJson(root, true); File.WriteAllText(Application.persistentDataPath + "/history.json", str); } string dataAsJson = File.ReadAllText(filepath); history = JsonUtility.FromJson <RootHistory>(dataAsJson).history; foreach (Element _element in history) { if (_element.value == element.value) { flg = true; } } if (!flg) { history.Add(element); } }
public static void SaveToHistory(Element element) { RootHistory historyJSON = new RootHistory(element); string str = ""; str = JsonUtility.ToJson(historyJSON, true); File.WriteAllText(Application.persistentDataPath + "/history.json", str); Debug.Log(Application.persistentDataPath); }
public static List <Element> ShowHistory() { string filepath = Application.persistentDataPath + "/history.json"; if (File.Exists(filepath)) { string dataAsJson = File.ReadAllText(filepath); RootHistory historyJSON = JsonUtility.FromJson <RootHistory>(dataAsJson); return(historyJSON.history); } return(null); }
public static void SaveToHistory(string _value, int _type, int _id) { Element element = new Element { id = _id, type = _type, value = _value }; RootHistory historyJSON = new RootHistory(element); string str = ""; str = JsonUtility.ToJson(historyJSON, true); File.WriteAllText(Application.persistentDataPath + "/history.json", str); Debug.Log(Application.persistentDataPath); }