void Update() { if (ChangeForLast == true) { _MusicPlayer.volume = 0; } if (_lastSceneNumber != SceneManager.GetActiveScene().buildIndex&& _change != true) { //Debug.Log ("_change = true"); _change = true; } if (SceneManager.GetActiveScene().buildIndex == 1) { /* * if (_MusicPlayer.volume != .5f) * { * AudioSlider.value = _MusicPlayer.volume; * }*/ //definition //slider if (AudioSlider == null) { AudioSlider = Slider.FindObjectOfType <Slider>(); } //on-off button if (OnOffButton == null) { OnOffButton = Toggle.FindObjectOfType <Toggle>(); } //changeMusic if (ChangeMusic == null) { ChangeMusic = Dropdown.FindObjectOfType <Dropdown>(); } //changes //check if first time with volume if (_change == true) { _lastSceneNumber = SceneManager.GetActiveScene().buildIndex; _change = false; ChangeMusic.value = globalVariables.changeMusicValue; OnOffButton.isOn = globalVariables.audioOn; AudioSlider.value = globalVariables.audioVolume; } else { //check if we have saved if (File.Exists(Application.persistentDataPath + "/MorpfSaves.txt") && _AlreadyLoaded == false) { Debug.Log("I'm Loading!"); _AlreadyLoaded = true; _change = true; globalVariables.changeMusicValue = SaveAndLoad.LoadChangeMusic(); globalVariables.audioOn = SaveAndLoad.LoadAudio(); globalVariables.audioVolume = SaveAndLoad.LoadVolume(); globalVariables.LevelTimeDone = SaveAndLoad.LoadLevelTimeDone(); } else { globalVariables.changeMusicValue = _changeMusicValue; globalVariables.audioOn = OnOffButton.isOn; globalVariables.audioVolume = AudioSlider.value; } } //change the music if (ChangeMusic != null) { _changeMusicValue = ChangeMusic.value; } //check if first time with button if (OnOffButton.isOn) { _MusicPlayer.volume = AudioSlider.value; } else { _MusicPlayer.volume = 0; } } if (CheckIfOk()) { //Debug.Log ("_musicPlayed = " + _musicPlayed); //Debug.Log ("Active Scenes = " + SceneManager.GetActiveScene ().buildIndex); /* * if(_musicPlayed != SceneManager.GetActiveScene ().buildIndex - 1) * { * _changeTipeOfMusic = true; * }*/ if (_afterChangeMusicValue != _changeMusicValue) { _changeTipeOfMusic = true; } if (!_MusicPlayer.isPlaying || (_musicPlayed != SceneManager.GetActiveScene().buildIndex - 1 && SceneManager.GetActiveScene().buildIndex - 1 >= 0)) { //Debug.Log ("Change!"); _changeTipeOfMusic = true; } if (_changeMusicValue == 0) { //Debug.Log ("Music1"); _afterChangeMusicValue = 0; DoMusic(_MusicList1); } else if (_changeMusicValue == 1) { //Debug.Log ("Music2"); _afterChangeMusicValue = 1; DoMusic(_MusicList2); } } }