示例#1
0
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var src = _targetAudioSource.GetTarget <AudioSource>(arg);

            if (src == null)
            {
                Debug.LogWarning("Failed to play audio due to a lack of AudioSource on the target.", this);
                return(false);
            }

            if (_interrupt == AudioInterruptMode.DoNotPlayIfPlaying && src.isPlaying)
            {
                return(false);
            }

            if (_settingsMask != 0)
            {
                _settings.Apply(src, _settingsMask);
            }

            if (_delay > 0f)
            {
                src.PlayDelayed(_delay);
            }
            else
            {
                src.Play();
            }

            return(true);
        }