15 [AddComponentMenu(
"UI/Extensions/UI Selectable Extension")]
16 [RequireComponent(typeof(Selectable))]
21 public class UIButtonEvent : UnityEvent<PointerEventData.InputButton> { }
25 [Tooltip(
"Event that fires when a button is initially pressed down")]
27 [Tooltip(
"Event that fires when a button is released")]
29 [Tooltip(
"Event that continually fires while a button is held down")]
33 private bool _pressed;
34 private PointerEventData _heldEventData;
36 void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
46 _heldEventData = eventData;
50 void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
59 _heldEventData =
null;
78 #if DEBUG || UNITY_EDITOR
79 Debug.Log(
"Control Clicked");
88 #if DEBUG || UNITY_EDITOR
89 Debug.Log(
"Control Pressed");
98 #if DEBUG || UNITY_EDITOR
99 Debug.Log(
"Control Released");
108 #if DEBUG || UNITY_EDITOR
109 Debug.Log(
"Control Held");
void TestHold()
est method to verify if a control is being held
UIButtonEvent OnButtonPress
void TestReleased()
est method to verify if a control is released
UIButtonEvent OnButtonHeld
void TestClicked()
Test method to verify a control has been clicked
UIButtonEvent OnButtonRelease
void TestPressed()
Test method to verify a control is pressed
Credit Erdener Gonenc - @PixelEnvision.