private void Awake() { if (instance == null) { instance = this; } }
private void Awake() { if (Singleton == null) { Singleton = this; } else { Debug.LogError("Attempted to create second UnlockCombos Singleton"); DestroyImmediate(this.gameObject); } }
public static void SavePlayerLevelAndExp(UnlockCombos player) { Debug.Log("Saving level and exp.."); BinaryFormatter bf = new BinaryFormatter(); string path = Application.persistentDataPath + "/playerlvl.dat"; FileStream file = new FileStream(path, FileMode.Create); try { PlayerStats stats = new PlayerStats(player.myexp, player.myLevel); bf.Serialize(file, stats); } catch (SerializationException e) { Debug.LogError($"an error saving playerstats {e.Message}"); } finally { file.Close(); } }