public void LoadGameData() { GameObject gameControllerObject = GameObject.Find("GameController") as GameObject; GameController gameController = gameControllerObject.GetComponent <GameController>(); string fileString = System.IO.File.ReadAllText(savePath + "gamedata.json"); SavableGameData sgd = new SavableGameData(); sgd = JsonUtility.FromJson <SavableGameData>(fileString); gameController.day = sgd.day; if (sgd.day % 7 == 0) { gameController.dayOfWeek = 1; } else { gameController.dayOfWeek = sgd.day % 7; } if (sgd.day % 2 == 1) { gameController.sunUp = true; } else { gameController.sunUp = false; } //maybe write a function for this later uiBank.GetComponent <UIBank>().dayText.text = "DAY " + sgd.day.ToString(); uiBank.GetComponent <UIBank>().weekText.text = gameController.dayOfWeek.ToString() + "/7"; }
public void SaveGameData(GameController gameController) { SavableGameData sgd = new SavableGameData(); sgd.day = gameController.day; string sgdString = JsonUtility.ToJson(sgd); System.IO.File.WriteAllText(savePath + "gamedata.json", sgdString); }