Пример #1
0
    void Save()
    {
        FileStream      file = File.Create(Application.persistentDataPath + "/Highscore.dat");
        BinaryFormatter bf   = new BinaryFormatter();

        SaveAble_Highscore saveAbleHighscoreData = new SaveAble_Highscore();

        saveAbleHighscoreData.Highscore = highscoreScript.Highscore;

        bf.Serialize(file, saveAbleHighscoreData);
        file.Close();
    }
Пример #2
0
    void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/Highscore.dat"))
        {
            FileStream      file = File.Open(Application.persistentDataPath + "/Highscore.dat", FileMode.Open);
            BinaryFormatter bf   = new BinaryFormatter();

            SaveAble_Highscore saveAbleHighscoreData = new SaveAble_Highscore();
            saveAbleHighscoreData     = (SaveAble_Highscore)bf.Deserialize(file);
            highscoreScript.Highscore = saveAbleHighscoreData.Highscore;

            file.Close();
        }
        else
        {
            print("creating new save file");
            Save();
        }
    }