Example #1
0
    static void SaveVersion()
    {
        BinaryFormatter bf   = new BinaryFormatter();                                        //create a binary formart
        FileStream      file = File.Create(Application.persistentDataPath + "/Version.dat"); //create a file called SavaData.dat
        VerionData      data = new VerionData();                                             // Create a data object using a serializable class

        data.gameVersion = version;                                                          //pass the variable mystate to data

        bf.Serialize(file, data);                                                            //write data on file
        file.Close();
    }
Example #2
0
    public void LoadVersionData()
    {
        if (File.Exists(Application.persistentDataPath + "/Version.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();                                                     //create a binary formart
            FileStream      file = File.Open(Application.persistentDataPath + "/Version.dat", FileMode.Open); //open the file called SavaData.dat
            VerionData      data = (VerionData)bf.Deserialize(file);                                          //Gets the data and put on the data variable
            file.Close();

            version = data.gameVersion;
            Debug.Log("Version " + version + " Loaded");
            SetText();
        }
        else
        {
            Debug.Log("Data doesn't exit");
        }
    }