void Awake() { if (HighScoreController.Instance != null) { Debug.LogError("[HighScoreController] - instance already set!!"); } else { HighScoreController.Instance = this; } this.highScoreCollection = HighScoreCollection.Load(); }
public static HighScoreCollection Load(string path) { if (!File.Exists(path)) { //if no high score exists yet, create one and save it HighScoreCollection highScoreCollection = new HighScoreCollection(); highScoreCollection.Save(); } var serializer = new XmlSerializer(typeof(HighScoreCollection)); using (var stream = new FileStream(path, FileMode.Open)) { return(serializer.Deserialize(stream) as HighScoreCollection); } }