Exemple #1
0
    public static void Save(SaveLoadScoreHandler handler)
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + $"/LeaderBoard.Koko");

        bf.Serialize(file, handler.GetData());
        file.Close();
    }
Exemple #2
0
    public static SaveLoadScoreHandler Load()
    {
        SaveLoadScoreHandler handler = new SaveLoadScoreHandler();

        if (File.Exists(Application.persistentDataPath + $"/LeaderBoard.Koko"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + $"/LeaderBoard.Koko", FileMode.Open);
            file.Position = 0;
            List <ScoreTeam> teams = (List <ScoreTeam>)bf.Deserialize(file);
            handler.SetData(teams);
            file.Close();
        }
        return(handler);
    }