| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | |
|
| | 4 | | public class GeneralHUDElementAudioHandler : MonoBehaviour, IPointerEnterHandler, IPointerDownHandler, IPointerUpHandler |
| | 5 | | { |
| | 6 | | [SerializeField] |
| 50652 | 7 | | protected bool playHover = true, playClick = true, playRelease = true; |
| | 8 | |
|
| | 9 | | public virtual void OnPointerEnter(PointerEventData eventData) |
| | 10 | | { |
| 0 | 11 | | if (!playHover) |
| 0 | 12 | | return; |
| | 13 | |
|
| 0 | 14 | | if (!Input.GetMouseButton(0)) |
| | 15 | | { |
| 0 | 16 | | AudioScriptableObjects.buttonHover.Play(true); |
| | 17 | | } |
| 0 | 18 | | } |
| | 19 | |
|
| | 20 | | public virtual void OnPointerDown(PointerEventData eventData) |
| | 21 | | { |
| 0 | 22 | | if (!playClick) |
| 0 | 23 | | return; |
| | 24 | |
|
| 0 | 25 | | AudioScriptableObjects.buttonClick.Play(true); |
| 0 | 26 | | } |
| | 27 | |
|
| | 28 | | public virtual void OnPointerUp(PointerEventData eventData) |
| | 29 | | { |
| 0 | 30 | | if (!playRelease) |
| 0 | 31 | | return; |
| | 32 | |
|
| 0 | 33 | | AudioScriptableObjects.buttonRelease.Play(true); |
| 0 | 34 | | } |
| | 35 | | } |