public void Load(string file) { FileStream fs = new FileStream(file, FileMode.Open); StreamUnpacker su = new StreamUnpacker(fs); // Save Parley ParleySaveLoad.Load(su); Debug.Log(su.ReadString()); // Save all the Objects foreach (GameObject go in packableObjects) { PackUnpackableBehaviour[] pus = (PackUnpackableBehaviour[])go.GetComponents <PackUnpackableBehaviour>(); Debug.Log("Parley: Loading details for object " + go.name); if (pus != null && pus.Length > 0) { foreach (PackUnpackableBehaviour pu in pus) { Debug.Log("Parley: Loading details for script " + pu.GetType().Name); Debug.Log("Parley: Saved Was " + su.ReadString()); pu.Unpack(su); } } pus = (PackUnpackableBehaviour[])go.GetComponentsInChildren <PackUnpackableBehaviour>(true); if (pus != null && pus.Length > 0) { foreach (PackUnpackableBehaviour pu in pus) { Debug.Log("Parley: Loading details for script " + pu.GetType().Name); Debug.Log("Parley: Saved Was " + su.ReadString()); pu.Unpack(su); } } } fs.Close(); }
public void Save(string file) { FileStream fs = new FileStream(file, FileMode.Create); StreamPacker sp = new StreamPacker(fs); // Save Parley ParleySaveLoad.Save(sp); sp.WriteString("All is well"); // Save all the Objects foreach (GameObject go in packableObjects) { PackUnpackableBehaviour[] pus = (PackUnpackableBehaviour[])go.GetComponents <PackUnpackableBehaviour>(); if (pus != null && pus.Length > 0) { foreach (PackUnpackableBehaviour pu in pus) { sp.WriteString(pu.GetType().Name); pu.Pack(sp); } } pus = (PackUnpackableBehaviour[])go.GetComponentsInChildren <PackUnpackableBehaviour>(true); if (pus != null && pus.Length > 0) { foreach (PackUnpackableBehaviour pu in pus) { sp.WriteString(pu.GetType().Name); pu.Pack(sp); } } } fs.Close(); }