Event Trigger component - how to access input data?

Hi there,

I’ve been using the Event Trigger component to easily handle events on various GameObjects. When simply wanting to call a function on an event triggering, I can just link the script and choose the function. If I want the function to require some parameters, I change the C# function definition and then add the parameter on my Event Trigger component.

My question is, what if the parameter I want to pass to my function is input data, such as the delta of the mouse or finger being dragged across the screen? Specifically, I have an Event Trigger Component with a Drag event which calls a function on a script. I want to access the Drag input data in that function.

Thanks in advance!

After discussing this in the forums (http://forum.unity3d.com/threads/event-trigger-component-how-to-access-input-data.291076/#post-1920576), I got a solution and I’m posting it here for future reference.

By making the function that is called by the Event Trigger require a BaseEventData argument, the information is passed into the function. Then one can cast the BaseEventData parameter as a PointerEventData:

PointerEventData pointerData = data as PointerEventData;

which makes pointerData contain information such as pointer position and delta.