public void addMon(string CODE, string Species) { PokeComp.Add(CODE); SpeciesSlot.Add(Species); BinaryFormatter BF = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/PC.dat"); PCdata data = new PCdata(); data.PokeComp = PokeComp; data.SpeciesSlot = SpeciesSlot; BF.Serialize(file, data); file.Close(); }
// Use this for initialization void Start() { DontDestroyOnLoad(this.gameObject); PokeComp = new List <string>(); SpeciesSlot = new List <string>(); if (File.Exists(Application.persistentDataPath + "/PC.dat")) { BinaryFormatter BF = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/PC.dat", FileMode.Open); PCdata data = (PCdata)BF.Deserialize(file); file.Close(); PokeComp = data.PokeComp; SpeciesSlot = data.SpeciesSlot; } }