//This loads your game file. public static FileData LoadGameFile(GameFile gameFile) { var path = FilePath(gameFile); if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); FileData data = formatter.Deserialize(stream) as FileData; stream.Close(); Debug.Log("Save File Loaded from " + path); return(data); } else { Debug.LogWarning("Save file not found in " + path); return(null); } }
//This creates the name of the gamefile. //IT CAN BE NAMED ANYTHING AFTER THE FORWARD SLASH. public static string FilePath(GameFile gameFile) { return(Application.persistentDataPath + "/" + gameFile.gameData.fileNumber + ".save"); }
public FileData(GameFile gameFile) { gameData = gameFile.gameData; }