Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public void Initialize()
 {
     itemData = this.LoadItems();
     Patch();
 }
Exemplo n.º 3
0
        public static void SaveItems(ContainerData itemData)
        {
            string json = JsonUtility.ToJson(itemData);

            File.WriteAllText(Application.persistentDataPath + "/Stash.json", json);
        }