public void Win() { win = true; pause_bg.SetActive(true); pauseMenu.SetActive(false); victoryMenu.SetActive(true); saveData file = DataLoad(); if (!file.completedLevels.Contains(gridParent.levelID)) { file.completedLevels.Add(gridParent.levelID); DataSave(file); } }
public static saveData DataLoad() { if (File.Exists(Application.persistentDataPath + "/saveData.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/saveData.dat", FileMode.Open); saveData toReturn = (saveData)bf.Deserialize(file); file.Close(); return(toReturn); } else { return(new saveData()); } }
void Start() { menuMain = GameObject.Find("main"); menuOptions = GameObject.Find("options"); GameObject.Find("camsens_value").GetComponent <Text>().text = GameObject.Find("camsensitivity").GetComponent <Slider>().value.ToString(); menuOptions.SetActive(false); savedStuff = DataLoad(); for (int i = 0; i < levelSelects.Length; i++) { Debug.Log("levelSelect" + i); levelSelects[i] = GameObject.Find("levelSelect" + i); levelSelects[i].SetActive(false); } }
public static void DataSave(saveData saveFile) { BinaryFormatter bf = new BinaryFormatter(); FileStream file; if (!File.Exists(Application.persistentDataPath + "/saveData.dat")) { Debug.Log("No save file. Creating new"); file = File.Create(Application.persistentDataPath + "/saveData.dat"); bf.Serialize(file, saveFile); file.Close(); } else { Debug.Log("Saving"); file = File.Open(Application.persistentDataPath + "/saveData.dat", FileMode.Open); bf.Serialize(file, saveFile); file.Close(); } }