public BackgroundMusicDependency() { audioManager = GameDependencies.Get<AudioManager>(); channel = audioManager.GetAvailableChannel(); audioManager.ClaimChannel(channel); }
private IEnumerator DoFade(AudioChannel channel , float start , float end , float steps) { float startTime = Time.time; channel.Volume = start; while (!channel.Volume.AlmostEquals(end , 0.05f)) { channel.Volume = Easing.EaseInOutQuad(start , end , Time.time - startTime); yield return null; } channel.Volume = end; onFadeCompleteEvent(channel); }
public void ReleaseChannel(AudioChannel channel) { if (claimedChannels.Contains(channel)) { claimedChannels.Remove(channel); } }
public void ClaimChannel(AudioChannel channel) { if (!claimedChannels.Contains(channel)) { claimedChannels.Add(channel); } }
public void FadeOut(AudioChannel channel , float steps) { if (channel != null && channel.IsPlaying) { StartCoroutine(DoFade(channel , 1 , 0 , steps)); } }
public void CrossFade(AudioChannel from , AudioChannel to , float steps) { FadeIn(to , steps); FadeOut(from , steps); }
public void CrossFade(AudioChannel from, AudioChannel to, float steps) { FadeIn(to, steps); FadeOut(from, steps); }