Пример #1
0
        private void PlayAudioClip(AudioClip[] audioClips, float range)
        {
            var audioSphere = AudioSourceManager.CreateAudioSourcePooled(transform.position, gameObject, categoryBitFlag);

            audioSphere.maxGrowthSize = range;
            if (audioClips.Length > 0)
            {
                audioSphere.audioSource.PlayOneShot(audioClips[Random.Range(0, audioClips.Length)]);
            }
            audioSphere.Emit();
        }
Пример #2
0
        protected virtual IAudioSource CreateAudiosource(Vector3 position)
        {
            var source = AudioSourceManager.CreateAudioSourcePooled(position, emitter.Value ?? gameObject, emitterCategoryBitFlag.Value);

            source.maxGrowthSize = range.Value;

            if (clip != null)
            {
                if (playOneShot)
                {
                    source.audioSource.PlayOneShot(clip, volume.Value);
                }
                else
                {
                    source.audioSource.clip = clip;
                    source.audioSource.Play();
                }
            }

            return(source);
        }