Exemplo n.º 1
0
    public void SaveFile(string currentName, float currentScore)
    {
        string     destination = Application.persistentDataPath + "/scoreboard.dat";
        FileStream file;

        if (File.Exists(destination))
        {
            file = File.OpenWrite(destination);
        }
        else
        {
            file = File.Create(destination);
        }
        int scoreInt = Mathf.RoundToInt(currentScore);

        scoreList.AddScore(currentName, scoreInt.ToString());
        BinaryFormatter bf = new BinaryFormatter();

        bf.Serialize(file, scoreList);
        file.Close();
    }