private void Update() { if (currentSound == null) { return; } switch (currentPlayingType) { case MusicPlayingType.None: break; case MusicPlayingType.SourceA: currentSound.DoFade(Time.deltaTime, fadeA_audio); break; case MusicPlayingType.SourceB: currentSound.DoFade(Time.deltaTime, fadeB_audio); break; case MusicPlayingType.AtoB: lastSound.DoFade(Time.deltaTime, fadeA_audio); currentSound.DoFade(Time.deltaTime, fadeB_audio); break; case MusicPlayingType.BtoA: lastSound.DoFade(Time.deltaTime, fadeB_audio); currentSound.DoFade(Time.deltaTime, fadeA_audio); break; } if (fadeA_audio.isPlaying == true && fadeB_audio.isPlaying == false) { currentPlayingType = MusicPlayingType.SourceA; } else if (fadeA_audio.isPlaying == false && fadeB_audio.isPlaying == true) { currentPlayingType = MusicPlayingType.SourceB; } else if (fadeA_audio.isPlaying == false && fadeB_audio.isPlaying == false) { currentPlayingType = MusicPlayingType.None; } }
// Update is called once per frame void Update() { if (currentSound == null) { return; } if (currentPlayingType == MusicPlayingType.SourceA) { currentSound.DoFade(Time.deltaTime, fadeA_audio); } else if (currentPlayingType == MusicPlayingType.SourceB) { currentSound.DoFade(Time.deltaTime, fadeB_audio); } else if (currentPlayingType == MusicPlayingType.AtoB) { this.lastSound.DoFade(Time.deltaTime, fadeA_audio); this.currentSound.DoFade(Time.deltaTime, fadeB_audio); } else if (currentPlayingType == MusicPlayingType.BtoA) { this.lastSound.DoFade(Time.deltaTime, fadeB_audio); this.currentSound.DoFade(Time.deltaTime, fadeA_audio); } if (fadeA_audio.isPlaying && this.fadeB_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.SourceA; } else if (fadeB_audio.isPlaying && fadeA_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.SourceB; } else if (fadeA_audio.isPlaying == false && fadeB_audio.isPlaying == false) { this.currentPlayingType = MusicPlayingType.None; } }