Exemplo n.º 1
0
    public void save(int newHighScore)
    {
        highScore = newHighScore;
        path      = Application.persistentDataPath + "/" + levelName + "scoreData.dat";

        levelHighScore data = new levelHighScore();

        data.highScore = highScore;

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(path);

        bf.Serialize(file, data);
        file.Close();
        Debug.Log("MANAGED TO SAVE FILE TO " + path);
        //writeFile
    }
Exemplo n.º 2
0
    public void load()
    {
        path = Application.persistentDataPath + "/" + levelName + "scoreData.dat";

        if (File.Exists(path))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(path, FileMode.Open);

            levelHighScore data = (levelHighScore)bf.Deserialize(file);
            highScore = data.highScore;
            file.Close();
            Debug.Log("MANAGED TO LOAD FILE FROM " + path);
        }
        else
        {
            save(highScore);
            load();
        }
    }