void Update()//maybe update? { if (!Loaded && SceneManager.GetActiveScene().name == "NewSelector") { string Name = "/" + GameObject.FindGameObjectWithTag("PassName").GetComponent <PassName>().NameToPass + ".dge"; if (File.Exists(Application.persistentDataPath + Name)) { using (FileStream file = File.Open(Application.persistentDataPath + Name, FileMode.Open)) { WhatToSave load = new WhatToSave(); BinaryFormatter bf = new BinaryFormatter(); load = (WhatToSave)bf.Deserialize(file); for (int i = 0; i < load.Completed.Length; i++) { GameObject.Find("ProgressKeeper").GetComponent <PrgKeeper>().Completed[i] = load.Completed[i]; } } } Loaded = true; } if (SceneManager.GetActiveScene().name != "NewSelector") { Loaded = false; } }
public void SaveOnChange() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/Sound.sdge", FileMode.OpenOrCreate); WhatToSave save = new WhatToSave(); save.Volume[0] = GameObject.Find("SoundMenu").GetComponent <VolumeHolder>().Volume[0]; save.Volume[1] = GameObject.Find("SoundMenu").GetComponent <VolumeHolder>().Volume[1]; bf.Serialize(file, save); file.Close(); Debug.Log("Volume Saved" + " (" + save.Volume[0] + ")" + " (" + save.Volume[1] + ")"); }
void Start() { if (File.Exists(Application.persistentDataPath + "/Sound.sdge")) { using (FileStream file = File.Open(Application.persistentDataPath + "/Sound.sdge", FileMode.Open)) { WhatToSave load = new WhatToSave(); BinaryFormatter bf = new BinaryFormatter(); load = (WhatToSave)bf.Deserialize(file); GameObject.Find("SoundMenu").GetComponent <VolumeHolder>().Volume[0] = load.Volume[0]; GameObject.Find("SoundMenu").GetComponent <VolumeHolder>().Volume[1] = load.Volume[1]; Debug.Log("Volume Loaded" + " (" + load.Volume[0] + ")" + " (" + load.Volume[1] + ")"); } } }
public void SaveData() { string Name = GameObject.Find("PassNameToSelector").GetComponent <PassName>().NameToPass; string Path = Application.persistentDataPath + "/" + Name + ".dge"; WhatToSave save = new WhatToSave(); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Path, FileMode.OpenOrCreate); for (int i = 0; i < save.Completed.Length; i++) { save.Completed[i] = GameObject.Find("ProgressKeeper").GetComponent <PrgKeeper>().Completed[i]; } bf.Serialize(file, save); file.Close(); Debug.Log("PROGRESS SAVED"); }
void EmptySave() { BinaryFormatter bf = new BinaryFormatter(); Debug.Log("Name It's Ok"); string Name = GameObject.FindGameObjectWithTag("PlayerNameField").GetComponent <TextMeshProUGUI>().text; FileStream file = File.Open(Application.persistentDataPath + "/" + Name + ".dge", FileMode.OpenOrCreate); WhatToSave save = new WhatToSave(); save.Completed[0] = true; for (int i = 1; i < save.Completed.Length; i++) { save.Completed[i] = false; } save.Completed[26] = true; bf.Serialize(file, save); file.Close(); }