Quantcast
Channel: Answers by "Narv"
Viewing all articles
Browse latest Browse all 60

Answer by Narv

$
0
0
You pretty much said it yourself. Using the binaryformatter to serialize a Deck class that stores a List and the Card class is just a series of public variables. Make sure your classes use [Serializable], and MonoBehavior can't be serialized so don't inherit from that (I haven't tested this, but I've read it somewhere else so this may have changed in Unity 5, im not sure). then: Deck mydeck = new Deck(generic_list_of_cards); FileStream fs = new FileStream(filename_location, FileMode.Open); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(fs, mydeck); fs.Close(); then you would do pretty much the same and do formatter.Deserailize() to get the data back out of the file.

Viewing all articles
Browse latest Browse all 60

Latest Images

Trending Articles





Latest Images