Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Xml;
- using System.Xml.Serialization;
- using System.IO;
- using System.Collections.Generic;
- [XmlRoot("CardCollection")]
- public class CardContainer
- {
- [XmlArray("Cards"),XmlArrayItem("Card")]
- public List<Card> Cards = new List<Card>();
- public void Save(string path)
- {
- var serializer = new XmlSerializer(typeof(CardContainer));
- using(var stream = new FileStream(path, FileMode.Create))
- {
- serializer.Serialize(stream, this);
- }
- }
- public static CardContainer Load(string path)
- {
- var serializer = new XmlSerializer(typeof(CardContainer));
- using(var stream = new FileStream(path, FileMode.Open))
- {
- return serializer.Deserialize(stream) as CardContainer;
- }
- }
- //Loads the xml directly from the given string. Useful in combination with www.text.
- public static CardContainer LoadFromText(string text)
- {
- var serializer = new XmlSerializer(typeof(CardContainer));
- return serializer.Deserialize(new StringReader(text)) as CardContainer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement