public override SoundInstance TestInEditor(ISoundPool soundPool) { ImpactSoundInstance sound = Fetch(soundPool, _velocityRange.ChooseRandom()); if (sound != null && (_cooldown <= 0 || TimeSinceLastPlayed > _cooldown)) { sound.Play2D(); OnPlayed(sound); return(sound); } return(null); }
public ImpactSoundInstance Fetch(ISoundPool soundPool, float impactVelocity) { ImpactSoundInstance sound = soundPool.FetchFromPool <ImpactSoundInstance>(); sound.name = name; sound.SetClip(GetNextClip()); sound.SetImpactVelocity(impactVelocity); sound.SetVelocityRange(_velocityRange.Min, _velocityRange.Max); sound.SetRolloffDistance(_rolloffDistance.Min, _rolloffDistance.Max); sound.SetMixerGroup(_outputMixer); sound.SetBaseVolume(_volumeRange.ChooseRandom()); sound.SetBasePitch(_pitchRange.ChooseRandom()); AddFilters(sound); return(sound); }