Created
April 13, 2016 10:36
-
-
Save moon-goon/7b3d21496d27e7b60268dcfa7b38753e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.IO; | |
public static class SaveLoad { | |
public static List<Game> savedGames = new List<Game>(); | |
public static void Save() { | |
SaveLoad.savedGames.Add(Game.current); | |
BinaryFormatter bf = new BinaryFormatter(); | |
FileStream file = File.Create (Application.persistentDataPath + "/savedGames.gd"); | |
bf.Serialize(file, SaveLoad.savedGames); | |
file.Close(); | |
} | |
public static void Load() { | |
if(File.Exists(Application.persistentDataPath + "/savedGames.gd")) { | |
BinaryFormatter bf = new BinaryFormatter(); | |
FileStream file = File.Open(Application.persistentDataPath + "/savedGames.gd", FileMode.Open); | |
SaveLoad.savedGames = (List<Game>)bf.Deserialize(file); | |
file.Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment