public void LoadData() { //Data is loaded if (File.Exists(Application.persistentDataPath + "/ganeInfo.dat")) { BinaryFormatter BinForm = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/ganeInfo.dat", FileMode.Open); DataPref data = (DataPref)BinForm.Deserialize(file); file.Close(); highScore = data.highScore; } }
//Awake happens before start void Awake() { if (dataManagement == null) { DontDestroyOnLoad(gameObject); dataManagement = this; } else if (dataManagement != this) { Destroy(gameObject); } }