private void Awake() { DataBaseMusic data = DataWork.LoadMusic(); musicSlider.value = data.musicVolume; effectsSlider.value = data.effectsVolume; }
void Awake() { _source = GetComponent <AudioSource>(); DataBaseMusic data = DataWork.LoadMusic(); _source.volume = data.musicVolume; if (main) { DontDestroyOnLoad(this.gameObject); } }
private void Start() { source = GetComponent <AudioSource>(); DataBaseMusic data = DataWork.LoadMusic(); source.volume = data.musicVolume; GameEngine.Engine.soundEffectVolume = data.effectsVolume; if (GameObject.Find("MusicBox") != null) { Destroy(GameObject.Find("MusicBox")); } }
public static void SaveMusic(float musicV, float effectsV) { //DataBase data = Load(); //data.musicVolume = musicV; //data.effectsVolume = effectsV; BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/Sound.vol"; FileStream stream = new FileStream(path, FileMode.Create); DataBaseMusic data = new DataBaseMusic(musicV, effectsV); formatter.Serialize(stream, data); stream.Close(); }
public static DataBaseMusic LoadMusic() { string path = Application.persistentDataPath + "/Sound.vol"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); DataBaseMusic data = formatter.Deserialize(stream) as DataBaseMusic; stream.Close(); return(data); } else { SaveMusic(0.7f, 0.7f); DataBaseMusic data = new DataBaseMusic(0.7f, 0.7f); return(data); } }