Example #1
0
        void Start()
        {
            SoundInstance sound = null;

            switch (_position)
            {
            case SoundPosition.TwoDimensional:
                sound = _soundBank.Play();
                break;

            case SoundPosition.TransformPosition:
                sound = _soundBank.Play(transform.position);
                break;

            case SoundPosition.FollowTransform:
                sound = _soundBank.Play(transform);
                break;
            }

            if (_loop)
            {
                EffectSoundInstance effectSound = sound as EffectSoundInstance;
                if (effectSound != null)
                {
                    effectSound.SetLooping(true);
                }
            }

            if (sound != null && _fadeInDuration > 0)
            {
                sound.FadeIn(_fadeInDuration, true);
            }
        }
Example #2
0
        public AmbienceSoundInstance AddLoop(AmbienceSoundBank.LoopData loopData)
        {
            Assert.IsFalse(IsPooled, "Tried to use SoundInstance while in pool. Make sure not to keep references to SoundInstances that have been destroyed.");
            Assert.IsNotNull(loopData);

            SoundInstance       loop       = loopData.Sound.Fetch(_soundPool);
            EffectSoundInstance effectLoop = loop as EffectSoundInstance;

            if (effectLoop != null)
            {
                effectLoop.SetLooping(true);
            }

            loop.SetDelay(_delayDuration);
            loop.SetAutoDestroy(false);

            if (loopData.Sound.IsClip)
            {
                effectLoop.SetRolloffDistance(loopData.RolloffDistance.Min, loopData.RolloffDistance.Max);
            }

            _loopSounds.Add(loop);
            _loopData.Add(loopData);
            _loopSeeds.Add(Random.value);

            RegisterChildSound(loop);

            return(this);
        }
Example #3
0
        public SequenceSoundInstance AddSection(SequenceSoundBank.SectionData sectionData)
        {
            Assert.IsFalse(IsPooled, "Tried to use SoundInstance while in pool. Make sure not to keep references to SoundInstances that have been destroyed.");
            Assert.IsNotNull(sectionData);

            SoundInstance       sound       = sectionData.Sound.Fetch(_soundPool);
            EffectSoundInstance effectSound = sound as EffectSoundInstance;

            if (effectSound != null)
            {
                effectSound.SetLooping(sectionData.Loop);
            }

            sound.SetDelay(sectionData.Delay);
            sound.SetAutoDestroy(false);

            if (sectionData.Sound.IsClip)
            {
                effectSound.SetRolloffDistance(sectionData.RolloffDistance.Min, sectionData.RolloffDistance.Max);
            }

            _sectionSounds.Add(sound);
            _sectionData.Add(sectionData);

            RegisterChildSound(sound);

            return(this);
        }