示例#1
0
    public void Save(float input)
    {
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        FileStream      file            = File.Create(Application.persistentDataPath + "/metronome_speed.dat");
        UserSpeed       data            = new UserSpeed();

        data.speed = input;

        binaryFormatter.Serialize(file, data);
        file.Close();
    }
示例#2
0
    public float Load()
    {
        if (File.Exists(Application.persistentDataPath + "/metronome_speed.dat"))
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            FileStream      file            = File.Open(Application.persistentDataPath + "/metronome_speed.dat", FileMode.Open);
            UserSpeed       data            = (UserSpeed)binaryFormatter.Deserialize(file);
            file.Close();

            return(data.speed);
        }
        else
        {
            return(80f);
        }
    }