private void Load() { string dataPath = Application.persistentDataPath + "/SaveGame.json"; string dataAsJson = File.ReadAllText(dataPath); JsonDataScript = JsonUtility.FromJson <JsonSaveGame>(dataAsJson); }
public bool SaveWorld()//Saves the the current world to the save file { SaveSettings(); SaveUnits(); //SaveTerrain(); //Write to file JsonSaveGame.SaveGame(currentSaveName, worldData); return(true); }
public bool LoadWorld()//Loads the data from the save file into the current world { //Read in from file worldData = JsonSaveGame.LoadGame(currentSaveName); LoadSettings(); LoadUnits(); //LoadTerrain(); return(true); }
//Starts a new game public void StartNewGame() { //Sets GameManager's saveName to the name entered by the user GameObject go = GameObject.Find("Canvas"); go = go.transform.Find("NewGameMenu").gameObject; GameManager.currentSaveName = go.transform.Find("NameInput").GetComponent <TMP_InputField>().text; //Creates a new save game file JsonSaveGame.CreateNewSaveGameFile(GameManager.currentSaveName); SceneManager.LoadSceneAsync("NewGameWorld"); Debug.Log("Starting a new game."); }