| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | public class ButtonAudioHandler : GeneralHUDElementAudioHandler |
| | 6 | | { |
| | 7 | | protected Selectable selectable; |
| | 8 | | [SerializeField] |
| | 9 | | AudioEvent extraClickEvent = null; |
| | 10 | |
|
| 11794 | 11 | | void Awake() { selectable = GetComponent<Selectable>(); } |
| | 12 | |
|
| | 13 | | public override void OnPointerEnter(PointerEventData eventData) |
| | 14 | | { |
| 0 | 15 | | if (selectable != null) |
| | 16 | | { |
| 0 | 17 | | if (selectable.interactable) |
| | 18 | | { |
| 0 | 19 | | base.OnPointerEnter(eventData); |
| | 20 | | } |
| | 21 | | } |
| 0 | 22 | | } |
| | 23 | |
|
| | 24 | | public override void OnPointerDown(PointerEventData eventData) |
| | 25 | | { |
| 0 | 26 | | if (selectable != null) |
| | 27 | | { |
| 0 | 28 | | if (selectable.interactable) |
| | 29 | | { |
| 0 | 30 | | base.OnPointerDown(eventData); |
| | 31 | | } |
| | 32 | | } |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | public override void OnPointerUp(PointerEventData eventData) |
| | 36 | | { |
| 0 | 37 | | if (selectable != null) |
| | 38 | | { |
| 0 | 39 | | if (selectable.interactable) |
| | 40 | | { |
| 0 | 41 | | base.OnPointerUp(eventData); |
| | 42 | |
|
| 0 | 43 | | if (extraClickEvent != null) |
| 0 | 44 | | extraClickEvent.Play(true); |
| | 45 | | } |
| | 46 | | } |
| 0 | 47 | | } |
| | 48 | | } |