public static void SaveAlMighty() { almightycurrentGame = new AlMightyGameState(); almightycurrentGame.UpdateVariables(); File.Delete(Application.persistentDataPath + "/AlMightySave.gd"); BinaryFormatter bf = new BinaryFormatter(); //Application.persistentDataPath is a string, so if you wanted you can put that into unitaleutil.writeinlog if you want to know where save games are located FileStream file = File.Create(Application.persistentDataPath + "/AlMightySave.gd"); bf.Serialize(file, almightycurrentGame); Debug.Log("AlMighty Save created at this location : " + Application.persistentDataPath + "/AlMightySave.gd"); file.Close(); }
public static bool LoadAlMighty() { if (File.Exists(Application.persistentDataPath + "/AlMightySave.gd")) { Debug.Log("We found an almighty save at this location : " + Application.persistentDataPath + "/AlMightySave.gd"); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/AlMightySave.gd", FileMode.Open); almightycurrentGame = (AlMightyGameState)bf.Deserialize(file); almightycurrentGame.LoadVariables(); file.Close(); return(true); } Debug.Log("There's no almighty save to load."); return(false); }
public static bool LoadAlMighty() { if (File.Exists(Application.persistentDataPath + "/AlMightySave.gd")) { Debug.Log("We found an almighty save at this location : " + Application.persistentDataPath + "/AlMightySave.gd"); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/AlMightySave.gd", FileMode.Open); almightycurrentGame = (AlMightyGameState)bf.Deserialize(file); almightycurrentGame.LoadVariables(); file.Close(); return(true); } else { Debug.Log("There's no almighty save to load... creating new one"); BinaryFormatter bf = new BinaryFormatter(); string locFile; if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) { locFile = "C:/Users/" + System.Environment.UserName + "/AppData/LocalLow/Nobody's Getting Paid Here/Create Your Frisk/AlMightySave.gd"; } else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) { locFile = "~/Library/Application Support/Nobody's Getting Paid Here/Create Your Frisk/AlMightySave.gd"; } else { locFile = "$XDG_CONFIG_HOME/unity3d/Nobody's Getting Paid Here/Create Your Frisk/AlMightySave.gd"; } if (File.Exists(locFile)) { FileStream file = File.Open(locFile, FileMode.Open); almightycurrentGame = (AlMightyGameState)bf.Deserialize(file); almightycurrentGame.LoadVariables(); file.Close(); SaveAlMighty(); return(true); } return(false); } }