+using UnityEngine;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+
+public static class SaveSystem
+{
+ public static void SavePlayer (CheckpointManager cm, Cheese cheese)
+ {
+ BinaryFormatter formatter = new BinaryFormatter();
+ string path = Application.persistentDataPath + "/data.lol";
+ FileStream stream = new FileStream(path, FileMode.Create);
+
+ PlayerData data = new PlayerData(cm, cheese);
+
+ formatter.Serialize(stream, data);
+ stream.Close();
+ }
+
+ public static PlayerData LoadPlayer ()
+ {
+ string path = Application.persistentDataPath + "/data.lol";
+ if (File.Exists(path))
+ {
+ BinaryFormatter formatter = new BinaryFormatter();
+ FileStream stream = new FileStream(path, FileMode.Open);
+
+ formatter.Deserialize(stream);
+
+ PlayerData data = formatter.Deserialize(stream) as PlayerData;
+ stream.Close();
+
+ return data;
+ }
+ else
+ {
+ Debug.LogError("Save file not found in" + path);
+ return null;
+ }
+ }
+}