Exemplo n.º 1
0
    void SaveState()
    {
        ClickHandler ch     = counterState.GetComponent <ClickHandler>();
        int          toSave = ch.GetCounter();

        Debug.Log("Saving " + toSave);

        string     destination = Application.persistentDataPath + "/save.dat";
        FileStream file;

        if (File.Exists(destination))
        {
            file = File.OpenWrite(destination);
        }
        else
        {
            file = File.Create(destination);
        }

        BinaryFormatter bf = new BinaryFormatter();

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