Пример #1
0
 //Application.persistentDataPath can be used to store to and read from appdata
 private void Awake()
 {
     if (fileName != null)
     {
         filePath = Application.dataPath + "/Json/" + fileName;
         Debug.Log("successfully loaded in: " + filePath);
     }
     else
     {
         filePath = Application.dataPath + "/Json/" + "default.json";
         Debug.Log("no file set, loaded in: " + filePath);
     }
     npcData = _wrapper.ReadData(filePath);
 }
Пример #2
0
    void ReadGameData()
    {
        JsonWrapper wrapper = new JsonWrapper();
        string      data    = wrapper.ReadData();

        try
        {
            GameData gameData = JsonUtility.FromJson <JsonWrapper>(data).gameData;
            gameManager.goldenBallsCollected = gameData.GoldenBallsCollected;
        }
        catch (System.Exception)
        {
            gameManager.goldenBallsCollected = 0;
        }
    }
Пример #3
0
    void LoadData()
    {
        int         gBallsCollected;
        JsonWrapper wrapper = new JsonWrapper();
        string      data    = wrapper.ReadData();

        try
        {
            GameData gameData = JsonUtility.FromJson <JsonWrapper>(data).gameData;
            gBallsCollected = gameData.GoldenBallsCollected;
        }
        catch (System.Exception)
        {
            gBallsCollected = 0;
        }
        goldenBallsText.text = "- " + gBallsCollected;
    }