Triggering UI button onmousedown, without waiting for mouseup event?
Is there any way to make the UI.Button Onclick event to activate when pressing the button without releasing it?
If not, what should be the correct way to emulate the behavior i'm specifying here?
I'm doing a small game that relies on pressing buttons in a UI. However, since they move/rotate, sometimes you feel you've pressed it, but the MouseUp event happens when your click is no longer raycasting, and then it doesn't count the tap.
Any way to make the UI Button onclick event to fire on MouseDown instantly?
Answer by Arkaid · Sep 13, 2016 at 02:11 AM
OnClick only triggers on mouse up, so you can't do it that way. What you can do is add a script of your own to the button that implements the OnPointerDown method, then raise your own event from there.
Thank you. I saw it as one of the events on event trigger, but for whatever reason I thought it was actually physically moving down the pointer, not actually pressing it.
Thanks again!
Your answer
![](https://koobas.hobune.stream/wayback/20220612092711im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Change TMP text color through event trigger 0 Answers
Refrence another text object from within a script involving PointerEnter and PointerExit 1 Answer
[Help] Event Trigger buttons not working? 1 Answer
Figuring out which function to call on button click 0 Answers
Cannot assign variable agents for clicking a button 0 Answers