difference between OnEndDrag and OnPointerUp

hi
what is the difference between OnEndDrag and OnPointerUp?
i want to call a function when stop dragging while the pointer is still down (Pointer.delta = vector2.zero). shouldn’t OnEndDrag do this? what should i use instead?

how can i call function every tick between pointerDown and pointerUp? i want to use pointer.IsPointerMoving() to fix this problem.

OnPointerUp is called whenever the pointer is released, regardless of weather or not it moved after being depressed.

OnDragEnd is only called when the pointer is released, IF a drag operation was started after the pointer was depressed.

note: OnDragBegin and OnDrag will be called BEFORE OnDragEnd.

I think your problem is due to the fact that once a “Drag” is STARTED, it not completed, until the pointer is released- even if the pointer stops moving.

For the custom behavior you are looking for you will probably need to use Update(), and manually check the pointer’s delta, as AlwaysSunny mentioned in the comments.

FYI: From what I’ve seen, it looks like there may be a little leeway for the end-user on when a “DRAG” operation is started; it looks like pointer movement must be above a certain threshold to actually trigger a “drag”.

@ALI3D69 : Here is another easy use, if you want to have two different events with your button, such as a “drag from button” and a “click on button” events.

    public bool isActivated= false;
    public Vector3 oldMousePosition;


    public void OnPointerDown(PointerEventData eventData)
    {
        oldMousePosition = Input.mousePosition;
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        if (!isActivated && Input.mousePosition == oldMousePosition)
        {
            //Do something or change a value
            isActivated= true;
        }
        else if (isActivated && Input.mousePosition == lastPosition)
        {
            //Do something or change a value
            isActivated= false;
        }
    }

This way, you’re not even going through the Update() and you’re saving resources.