Beispiel #1
0
    public void SaveGameScore(int gameScore)
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/GameScore.dat");
        GameScoreSave   data = new GameScoreSave();

        data.gameScore = gameScore;
        bf.Serialize(file, data);
        file.Close();
    }
Beispiel #2
0
 public int LoadGameScore()
 {
     if (File.Exists(Application.persistentDataPath + "/GameScore.dat"))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(Application.persistentDataPath + "/GameScore.dat", FileMode.Open);
         GameScoreSave   data = (GameScoreSave)bf.Deserialize(file);
         file.Close();
         return(data.gameScore);
     }
     else
     {
         Debug.LogError("There is no save data!");
     }
     return(0);
 }