示例#1
0
        public virtual void PlaySound(AnimationEvent e)
        {
            if (e.animatorClipInfo.weight < 0.1)
            {
                return;                                  // if is too small the weight of the animation clip do nothing
            }
            EventSound SoundEvent = m_EventSound.Find(item => item.name == e.stringParameter);

            if (SoundEvent != null && SoundEvent.active)
            {
                SoundEvent.VolumeWeight = e.animatorClipInfo.weight;

                if (anim)
                {
                    _audioSource.pitch = anim.speed;                           //Match the AnimatorSpeed with the Sound Pitch
                }
                if (_audioSource.isPlaying)                                    //If the Audio is already Playing play the one that has more weight
                {
                    if (SoundEvent.VolumeWeight * SoundEvent.volume > _audioSource.volume)
                    {
                        SoundEvent.PlayAudio(_audioSource);
                    }
                }
                else
                {
                    SoundEvent.PlayAudio(_audioSource);
                }
            }
        }
示例#2
0
        public virtual void EnableSoundEvent(string SoundName)
        {
            EventSound SoundEvent = m_EventSound.Find(item => item.name == SoundName);

            if (SoundEvent != null)
            {
                SoundEvent.active = true;
            }
        }
示例#3
0
        IEnumerator C_Playforever(EventSound E_sound)
        {
            if (E_sound.interval <= 0)
            {
                yield return(null);
            }
            else
            {
                var timeInterval = new WaitForSeconds(E_sound.interval);
                while (true)
                {
                    E_sound.PlayAudio(_audioSource);
                    yield return(timeInterval);
                }
            }

            yield return(null);
        }