private void forceStopBGM() { TWAudioQueue.SourceData sourceLast = bgmQueue.GetLastActive(); if (coroutines[sourceLast.ID] != null) { StopCoroutine(coroutines[sourceLast.ID]); } sourceLast.audio.volume = 0; sourceLast.audio.clip = null; sourceLast.audio.Stop(); coroutines[sourceLast.ID] = null; }
private void playBGMDefault(string musicName, bool loop) { TWAudioQueue.SourceData activeSource = bgmQueue.ChangeActiveChannel(); if (!activeSource.audio.isPlaying && activeSource.audio.clip == null) { activeSource.audio.clip = audioLibrary.GetBGMClip(musicName); activeSource.audio.loop = loop; activeSource.audio.volume = 1; activeSource.audio.Play(); return; } }
private void playBGMOverride(string musicName, bool loop) { TWAudioQueue.SourceData activeSource = bgmQueue.ChangeActiveChannel(); if (!activeSource.audio.isPlaying && activeSource.audio.clip == null) { activeSource.audio.clip = audioLibrary.GetBGMClip(musicName); activeSource.audio.loop = loop; activeSource.audio.volume = 0; activeSource.audio.Play(); StartCoroutine(fadeAudio(activeSource.audio, true)); return; } }
private void playBGMAuto(string musicName, bool loop) { TWAudioQueue.SourceData activeSource = bgmQueue.ChangeActiveChannel(); TWAudioQueue.SourceData lastSource = bgmQueue.GetLastActive(); if (lastSource.audio.isPlaying) { coroutines[lastSource.ID] = StartCoroutine(fadeAudio(lastSource.audio, false, () => { coroutines[lastSource.ID] = null; })); } if (!activeSource.audio.isPlaying && activeSource.audio.clip == null) { activeSource.audio.clip = audioLibrary.GetBGMClip(musicName); activeSource.audio.loop = loop; activeSource.audio.volume = 0; activeSource.audio.Play(); coroutines[activeSource.ID] = StartCoroutine(fadeAudio(activeSource.audio, true, () => { coroutines[activeSource.ID] = null; })); } }