protected void AddFilters(SoundInstance sound) { sound.AddFilter(_distortionFilter); sound.AddFilter(_lowPassFilter); sound.AddFilter(_highPassFilter); sound.AddFilter(_chorusFilter); sound.AddFilter(_echoFilter); sound.AddFilter(_reverbFilter); sound.AddFilter(_startFadeFilter); sound.AddFilter(_endFadeFilter); sound.AddFilter(_volumeCurveFilter); sound.AddFilter(_pitchCurveFilter); }
public override void UpdateSound(float deltaTime) { Assert.IsFalse(IsPooled, "Tried to use SoundInstance while in pool. Make sure not to keep references to SoundInstances that have been destroyed."); base.UpdateSound(deltaTime); if (_state == State.Playing) { for (int i = 0; i < _loopSounds.Count; i++) { if (!_loopSounds[i].IsPlaying) { _loopSounds[i].Play(_positionMode, _followTransform, transform.position); } _loopSeeds[i] += deltaTime * _loopData[i].VaritaionFrequency; _loopSounds[i].SetParentMultipliers(_loopData[i].VolumeVariationRange.GetValue(Noise.GetNormalizedPerlin(_loopSeeds[i])) * _volumeMultiplier * _parentVolumeMultiplier, _pitchMultiplier * _parentPitchMultiplier); } for (int i = 0; i < _effectData.Count; i++) { _effectCooldowns[i] -= deltaTime; if (_effectCooldowns[i] <= 0) { SoundInstance effect = _effectData[i].Sound.Fetch(_soundPool); effect.SetDelay(_delayDuration); effect.SetParentMultipliers(_volumeMultiplier * _parentVolumeMultiplier, _pitchMultiplier * _parentPitchMultiplier); for (int j = 0; j < _filters.Count; j++) { effect.AddFilter(_filters[j]); } if (_mixerGroup != null) { effect.SetMixerGroup(_mixerGroup); } if (_effectData[i].Sound.IsClip) { (effect as EffectSoundInstance).SetRolloffDistance(_effectData[i].SpawnDistance.Min, _effectData[i].SpawnDistance.Max); } switch (_positionMode) { case PositionMode.TwoDimensional: effect.Play(PositionMode.TwoDimensional, null, Vector3.zero); break; case PositionMode.FixedPosition: effect.Play(PositionMode.FixedPosition, null, GetEffectPosition(_effectData[i], transform.position)); break; case PositionMode.FollowingTransform: effect.Play(PositionMode.FixedPosition, null, GetEffectPosition(_effectData[i], _followTransform.position)); break; } _effectCooldowns[i] = _effectData[i].Cooldown.ChooseRandom(); _effectSounds.Add(effect); RegisterChildSound(effect); effect.OnFinish(() => DeregisterEffect(effect)); } } } if (HasFinished && _autoDestroy) { StopAndDestroy(); } }