Пример #1
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Пример #2
0
 private void Awake()
 {
     if (Singleton == null)
     {
         Singleton = this;
     }
     else
     {
         Debug.LogError("Attempted to create second UnlockCombos Singleton");
         DestroyImmediate(this.gameObject);
     }
 }
Пример #3
0
    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();
        }
    }