private void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/" + _fileName, FileMode.OpenOrCreate); VolumeData data = new VolumeData(_ambianceVolume, _soundEffectVolume); bf.Serialize(file, data); file.Close(); }
private void Load() { if (File.Exists(Application.persistentDataPath + "/" + _fileName)) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/" + _fileName, FileMode.Open); VolumeData data = (VolumeData)bf.Deserialize(file); file.Close(); _ambianceVolume = data.ambiance; _soundEffectVolume = data.soundEffect; } }