Exemple #1
0
    void LoadState()
    {
        string     destination = Application.persistentDataPath + "/save.dat";
        FileStream file;

        if (File.Exists(destination))
        {
            file = File.OpenRead(destination);
        }
        else
        {
            Debug.LogError("File not found");
            return;
        }

        BinaryFormatter bf     = new BinaryFormatter();
        int             loaded = (int)bf.Deserialize(file);

        file.Close();

        Debug.Log("Loading " + loaded);
        ClickHandler ch = counterState.GetComponent <ClickHandler>();

        ch.SetCounter(loaded);
    }