public void StopMusic() { if (currentMusic.IsPlaying) { currentMusic.DOFadeToStop(MusicFadeTime); } currentMusic = new SoundHandle(); }
public void PlayMusic(AudioClip clip, float volume) { if (currentMusic.IsPlaying) { if (currentMusic.AudioClip == clip) { currentMusic.Volume = volume; return; } currentMusic.DOFadeToStop(MusicFadeTime); } currentMusic = Music.Play(clip, true, true, 0.0f); currentMusic.DOKill(false); currentMusic.DOFade(1.0f, MusicFadeTime); }
public void Stop(SoundHandle handle) { if (!handle.IsValid) { DebugOnly.Error("Attempted to stop sound with an invalid SoundHandle."); return; } int n = soundSources.Count; while (n-- > 0) { if (soundSources[n] == handle.Source) { soundSources.RemoveAt(n); handle.Source.Dispose(); return; } } DebugOnly.Error("Attempted to stop sound that is not playing in this channel."); }