public ContainerData LoadItems() { if (!File.Exists(Application.persistentDataPath + "/Stash.json")) { StreamWriter sw = File.CreateText(Application.persistentDataPath + "/Stash.json"); sw.Close(); string json = "{\"itemList\":[]}"; File.WriteAllText(Application.persistentDataPath + "/Stash.json", json); Debug.Log("Blank json created at " + Application.persistentDataPath); } using (StreamReader streamReader = new StreamReader(Application.persistentDataPath + "/Stash.json")) { ContainerData itemData = JsonUtility.FromJson <ContainerData>(streamReader.ReadToEnd()); return(itemData); } }
public void Initialize() { itemData = this.LoadItems(); Patch(); }
public static void SaveItems(ContainerData itemData) { string json = JsonUtility.ToJson(itemData); File.WriteAllText(Application.persistentDataPath + "/Stash.json", json); }