Example #1
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);
        }
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 EffectSoundInstance Fetch(ISoundPool soundPool)
        {
            EffectSoundInstance sound = soundPool.FetchFromPool <EffectSoundInstance>();

            sound.name = name;
            sound.SetClip(GetNextClip());
            sound.SetRolloffDistance(_rolloffDistance.Min, _rolloffDistance.Max);
            sound.SetMixerGroup(_outputMixer);
            sound.SetBaseVolume(_volumeRange.ChooseRandom());
            sound.SetBasePitch(_pitchRange.ChooseRandom());

            AddFilters(sound);

            return(sound);
        }