private IEnumerator ReturnToPool(AudioSourceAnimator animator) { yield return(new WaitForSeconds(animator.Source.clip.length / animator.Source.pitch)); animator.Source.Stop(); Pool.Return(animator.Source); Animators.Remove(animator); }
private IEnumerator ManageLoop(AudioSourceAnimator animator, LoopGroup group, EffectFader fader) { var FadeControl = new VolumeControl(0.0f); animator.AddControl(FadeControl); while (true) { fader.Update(Time.deltaTime); FadeControl.Volume = fader.Value; yield return(null); } }
public void PlayMusic(MusicGroup group) { var source = Pool.Grab(); source.clip = group.Music[0]; source.volume = group.Volume; source.priority = 1024; source.loop = true; var animator = new AudioSourceAnimator(source, TabFade, MasterVolume, MusicVolume); Animators.Add(animator); source.Play(); }
public void PlayClip(LoopGroup group, EffectFader fader) { var source = Pool.Grab(); source.clip = group.LoopedAudio; source.pitch = group.PitchRange.x; source.volume = group.VolumeRange.x; source.loop = true; var animator = new AudioSourceAnimator(source, TabFade, MasterVolume, SfxVolume); Animators.Add(animator); source.Play(); StartCoroutine(ManageLoop(animator, group, fader)); }
public void PlayClip(SfxGroup group) { var source = Pool.Grab(); source.clip = group.GetClip(); source.volume = UnityEngine.Random.Range(group.VolumeRange.x, group.VolumeRange.y); source.pitch = UnityEngine.Random.Range(group.PitchRange.x, group.PitchRange.y); source.loop = false; var animator = new AudioSourceAnimator(source, TabFade, MasterVolume, SfxVolume); Animators.Add(animator); source.Play(); StartCoroutine(ReturnToPool(animator)); }