Example #1
0
        public override SoundInstance TestInEditor(ISoundPool soundPool)
        {
            AmbienceSoundInstance sound = Fetch(soundPool);

            if (sound != null)
            {
                if (_audioListener == null)
                {
                    _audioListener = FindObjectOfType <AudioListener>();
                }

                if (_audioListener != null)
                {
                    sound.Play3D(_audioListener.transform.position);
                }
                else
                {
                    sound.Play2D();
                }
                OnPlayed(sound);

                return(sound);
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// Fetches and then plays a non-spatial sound, ie. one that does not emit from a specific location and rolloff.
        /// </summary>
        /// <param name="soundBank">The sound bank used to set-up the sound instance</param>
        public static AmbienceSoundInstance Play(this AmbienceSoundBank soundBank)
        {
            if (soundBank != null)
            {
                AmbienceSoundInstance sound = soundBank.Fetch(RuntimeSoundPool.Instance);
                sound.Play2D();
                soundBank.OnPlayed(sound);

                return(sound);
            }

            return(null);
        }