示例#1
0
        void OnParticleCollision(GameObject other)
        {
            if (!OnParticleCollisionActivated)
            {
                return;
            }

            AudioSubscription sub = FindSubscriptionForEvent(AudioSourceStandardEvent.OnParticleCollision);

            if (sub == null)
            {
                return;
            }

            if (sub.filterLayers && (sub.layerMask & 1 << other.layer) != 0)
            {
                return;
            }
            if (sub.filterTags && !sub.tags.Contains(other.tag))
            {
                return;
            }
            if (sub.filterNames && !sub.names.Contains(other.name))
            {
                return;
            }

            PlaySoundInternal(AudioSourceStandardEvent.OnParticleCollision);
        }
示例#2
0
        void OnCollisionEnter(Collision collision)
        {
            if (!OnCollisionEnterActivated)
            {
                return;
            }

            AudioSubscription sub = FindSubscriptionForEvent(AudioSourceStandardEvent.OnCollisionEnter);

            if (sub == null)
            {
                return;
            }

            if (sub.filterLayers && (sub.layerMask & 1 << collision.gameObject.layer) != 0)
            {
                return;
            }
            if (sub.filterTags && !sub.tags.Contains(collision.gameObject.tag))
            {
                return;
            }
            if (sub.filterNames && !sub.names.Contains(collision.gameObject.name))
            {
                return;
            }

            PlaySoundInternal(AudioSourceStandardEvent.OnCollisionEnter);
        }
示例#3
0
        void OnTriggerExit(Collider other)
        {
            if (!OnTriggerExitActivated)
            {
                return;
            }

            AudioSubscription sub = FindSubscriptionForEvent(AudioSourceStandardEvent.OnTriggerExit);

            if (sub == null)
            {
                return;
            }

            if (sub.filterLayers && (sub.layerMask & 1 << other.gameObject.layer) != 0)
            {
                return;
            }
            if (sub.filterTags && !sub.tags.Contains(other.gameObject.tag))
            {
                return;
            }
            if (sub.filterNames && !sub.names.Contains(other.gameObject.name))
            {
                return;
            }

            PlaySoundInternal(AudioSourceStandardEvent.OnTriggerExit);
        }
示例#4
0
        /// <summary>
        /// Calls the correct play handler by AudioSourceStandardEvent.
        /// </summary>
        void PlaySoundInternal(AudioSourceStandardEvent evt)
        {
            AudioSubscription sub = FindSubscriptionForEvent(evt);

            if (sub == null)
            {
                return;
            }

            switch (sub.actionType)
            {
            case AudioSourceAction.Play:
                PlayHandler();
                break;

            case AudioSourceAction.PlayLoop:
                PlayLoopHandler();
                break;

            case AudioSourceAction.PlayCapped:
                PlayCappedHandler(sub.cappedName);
                break;

            case AudioSourceAction.Stop:
                StopHandler();
                break;

            case AudioSourceAction.None:
            default:
                return;
            }
        }