Beispiel #1
0
    /******************
    *
    *
    *   RATING
    *
    *
    ******************/

    public void SaveRating(int num)
    {
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        FileStream      file            = File.Create(Application.persistentDataPath + "/upRating.dat");
        UPRating        data            = new UPRating();

        //Save score to data.score
        data.rating = num;
        print("Rating saved!");
        binaryFormatter.Serialize(file, data);
        file.Close();
    }
Beispiel #2
0
    public int LoadRating()
    {
        if (File.Exists(Application.persistentDataPath + "/upRating.dat"))
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            FileStream      file            = File.Open(Application.persistentDataPath + "/upRating.dat", FileMode.Open);
            UPRating        data            = (UPRating)binaryFormatter.Deserialize(file);
            file.Close();

            return(data.rating);
        }
        else
        {
            print("You have not yet rated this app.");
            return(-1);
        }
    }