예제 #1
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/leaderboard" + Settings.textFormat))
        {
            BinaryFormatter  bf   = new BinaryFormatter();
            FileStream       file = File.Open(Application.persistentDataPath + "/leaderboard" + Settings.textFormat, FileMode.Open);
            SavedLeaderBoard data = (SavedLeaderBoard)bf.Deserialize(file);
            file.Close();

            // choose vars to be loaded

            leaderBoardData        = data.leaderboard;
            autoApplyToLeaderboard = data.autoApplyToLeaderboard;
            username = data.username;
        }
    }
예제 #2
0
    public void Reset()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/leaderboard" + Settings.textFormat);

        SavedLeaderBoard data = new SavedLeaderBoard();

        // choose vars to be default

        data.leaderboard = leaderBoardDataBase;
        data.username    = "";

        // saving and closing file
        bf.Serialize(file, data);
        file.Close();
        Load();
    }
예제 #3
0
    }// setting the username in the inputfield so you dont need to type it more than once

    // save methods
    public void Save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/leaderboard" + Settings.textFormat);

        SavedLeaderBoard data = new SavedLeaderBoard();

        // insert vars to be saved

        data.leaderboard            = leaderBoardData;
        data.autoApplyToLeaderboard = autoApplyToLeaderboard;
        data.username = username;

        // saving and closing file
        bf.Serialize(file, data);
        file.Close();
    }