- Home /
4.6 UI - OnPointerUp event doesn't fire if button released in different canvas child
I'm trying to make a UI in Unity 4.6 where I drag items from an inventory to a hotbar, which are separate entities in the canvas. For some reason, when I click drag from the inventory to the hotbar, the OnPointerUp event never fires. OnPointerDown works fine, and OnPointerClick also, and OnPointerUp will also fire if I'm keeping the cursor within the same child of the Canvas.
Anything I could be doing wrong?
I'm not sure you completely understood me.
If I used a OnPointerClick on the same image, it fires when I click it. If the cursor is present(over the image) for both OnPointerDown and OnPointerUp, it will fire OnPointerUp. If I press the mouse button over another element and then move to this one to release it, the OnPointerUp event will not fire. I have tried with the BeginDrag and EndDrag events and I couldn't get them to fire either.
I found this, it seems to suggest that any time the mouse button is released over something should fire OnPointerUp: http://forum.unity3d.com/threads/difference-between-onenddrag-and-onpointerup.305154/
Did you find a solution to this? I have the same issue, (and find the answer provided of no use). Both OnPointerUp and OnEndDrag fires the event on the object where the drag initiated. Not where the drag ended..
Answer by TSRajesh · Aug 09, 2015 at 02:57 AM
For anyone who find this issue.. The Answer is IDropHandler.OnDrop It fires in the object in the End position instead of Starting Position.
Answer by DiegoSLTS · Feb 22, 2015 at 04:40 PM
There's nothing wrong, that's how OnPointerUp works. The pointer should be over the object when you release it for the event to be triggered.
Try something else, maybe what you want is OnEndDrag. If you're using the Event Trigger component you can add things for that event like you did for the rest. If you're doing it all by code you need to extend the IEndDragHandler interface on your script (and maybe IDragHandler too, I'm not sure).
Your answer
![](https://koobas.hobune.stream/wayback/20220613183940im_/https://answers.unity.com/themes/thub/images/avi.jpg)