/// <summary> /// Stop playing FX at channel. /// </summary> /// <param name="channel">Channel.</param> public void StopFX(SoundFXChannel channel) { var fx = _fxes[(int)channel]; if (fx.isPlaying) { fx.Stop(); } fx.clip = null; }
/// <summary> /// Play FX. /// </summary> /// <param name="clip">AudioClip object.</param> /// <param name="channel">Channel for playing.</param> /// <param name="forceInterrupt">Force interrupt previous FX at chanel.</param> public void PlayFX(AudioClip clip, SoundFXChannel channel = SoundFXChannel.First, bool forceInterrupt = false) { var fx = _fxes[(int) channel]; if (!forceInterrupt && fx.isPlaying) { return; } StopFX (channel); fx.clip = clip; if (SoundVolume > 0f && clip != null) { fx.Play (); } }
/// <summary> /// Play FX. /// </summary> /// <param name="clip">AudioClip object.</param> /// <param name="channel">Channel for playing.</param> /// <param name="forceInterrupt">Force interrupt previous FX at chanel.</param> public void PlayFX(AudioClip clip, SoundFXChannel channel = SoundFXChannel.First, bool forceInterrupt = false) { var fx = _fxes[(int)channel]; if (!forceInterrupt && fx.isPlaying) { return; } StopFX(channel); fx.clip = clip; if (SoundVolume > 0f && clip != null) { fx.Play(); } }
/// <summary> /// Stop playing FX at channel. /// </summary> /// <param name="channel">Channel.</param> public void StopFX(SoundFXChannel channel) { var fx = _fxes[(int) channel]; if (fx.isPlaying) { fx.Stop (); } fx.clip = null; }