예제 #1
0
    public void ReadData()
    {
        try {
            if (File.Exists(fullPath))
            {
                string       contents = File.ReadAllText(fullPath);
                JSON_Wrapper wrapper  = JsonUtility.FromJson <JSON_Wrapper>(contents);
                saveList = wrapper.saveList;

                foreach (GameObject go in testObjects)
                {
                    if (go != null)
                    {
                        Destroy(go.gameObject);
                    }
                }
                testObjects.Clear();

                foreach (Test_Object obj in saveList.Save_Objects_Json)
                {
                    Debug.Log(obj.objectID);
                    LoadObjects(obj);
                }
            }
            else
            {
                Debug.Log("No File");
                test_Object = new Test_Object();
            }
        } catch (System.Exception ex)
        {
            Debug.Log(ex.Message);
        }
    }
예제 #2
0
    public void SaveDataUI()
    {
        updateList();


        JSON_Wrapper wrapper = new JSON_Wrapper();

        wrapper.saveList = saveList;
        string contents = JsonUtility.ToJson(wrapper, true);

        if (File.Exists(fullPath))
        {
            File.Delete(fullPath);
            File.WriteAllText(fullPath, contents);
        }
        else
        {
            File.WriteAllText(fullPath, contents);
        }
    }