private void OnValueUpdated(SliderEventData eventData) { if (playTickSounds && passNotchAudioSource != null && passNotchSound != null) { float delta = eventData.NewValue - eventData.OldValue; accumulatedDeltaSliderValue += Mathf.Abs(delta); var now = Time.timeSinceLevelLoad; if (accumulatedDeltaSliderValue > tickEvery && now - lastSoundPlayTime > minSecondsBetweenTicks) { passNotchAudioSource.pitch = Mathf.Lerp(startPitch, endPitch, eventData.NewValue); passNotchAudioSource.PlayOneShot(passNotchSound); accumulatedDeltaSliderValue = 0; lastSoundPlayTime = now; } } }