How to force Eventsystem Drag

So, i’m making a virtual joystick for my android game, the joystick anchor its position to where the user touches on the screen, and the whole process of moving the joystick is made through IDragHandler, IBeginDragHandler, IEndDragHandler.

The problem is that the events from Eventsystem are called before the Touch, so when i touch the screen Eventsystem will compute an empty space and then the touch will move the joystick to the touched position.

How can i force Eventsystem to execute BeginDrag after the joystick have being moved to its position?

I know that there’s the ExecuteEvents.Execute(); but i can only make PointerUp and Down to work, drag dosen’t.

Found out a solution.

First i was trying to use ExecuteEvents.Execute() passing a new PointerEventData which dosen’t work, you have to use the current PointerEventData from the EventSystem you can get it in most EventSystem interfaces like: IPointerClickHandler

public void OnPointerClick(PointerEventData eventData)
{
    if(JoystickController.CurrentPointer == null)
    {
        //Store the EventSystem PointerEventData for future use.
        JoystickController.CurrentPointer = eventData;
    }
}

Than just store it somewhere, and at the Touch or Mouse click call, you have to set the pointerDrag object and call the ExecuteEvents with the event initializePotentialDrag, like:

CurrentPointer.pointerDrag = joystick.gameObject;

ExecuteEvents.Execute(joystick.gameObject, CurrentPointer, ExecuteEvents.initializePotentialDrag);

Note. You can’t call ExecuteEvents from the same object that will recieve the Event, it won’t work.