| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | public class SliderAudioHandler : MonoBehaviour, IPointerDownHandler, IPointerUpHandler |
| | 6 | | { |
| | 7 | | Slider slider; |
| | 8 | |
|
| | 9 | | void Awake() |
| | 10 | | { |
| 18 | 11 | | slider = GetComponent<Slider>(); |
| 18 | 12 | | slider.onValueChanged.AddListener(OnValueChanged); |
| 18 | 13 | | } |
| | 14 | |
|
| | 15 | | public void OnPointerDown(PointerEventData eventData) |
| | 16 | | { |
| 0 | 17 | | if (slider != null) |
| | 18 | | { |
| 0 | 19 | | if (slider.interactable) |
| | 20 | | { |
| 0 | 21 | | AudioScriptableObjects.buttonClick.Play(true); |
| | 22 | | } |
| | 23 | | } |
| 0 | 24 | | } |
| | 25 | |
|
| | 26 | | public void OnPointerUp(PointerEventData eventData) |
| | 27 | | { |
| 0 | 28 | | if (slider != null) |
| | 29 | | { |
| 0 | 30 | | if (slider.interactable) |
| | 31 | | { |
| 0 | 32 | | AudioScriptableObjects.buttonRelease.Play(true); |
| | 33 | | } |
| | 34 | | } |
| 0 | 35 | | } |
| | 36 | |
|
| | 37 | | void OnValueChanged(float value) |
| | 38 | | { |
| 20 | 39 | | AudioScriptableObjects.sliderValueChange.SetPitch(1f + ((slider.value - slider.minValue) / (slider.maxValue - sl |
| 20 | 40 | | AudioScriptableObjects.sliderValueChange.Play(true); |
| 20 | 41 | | } |
| | 42 | | } |