- Home /
EventSystem - Broadcast my own Input
Hello,
I have a bunch of coordinates being fed into Unity from an external source. These coordinates are in Vector2, with respect to Unity's Canvas.
I would like to insert these coordinates into Unity's EventSystem as an input 'IPointerEnterHandler'. However there could be multiple inputs in one frame, thus it needs to support Multitouch.
Does anyone have an idea how I can approach this? Thanks.
Hi, just a general info, I'd derive from StandaloneInput$$anonymous$$odule and override some methods there. I've never did that for mul$$anonymous$$ch though so maybe it's not enough customization. I guess the other option is to modify the Unityengine.UI source from the Bitbucket repo, as a last resort...
Answer by RahulOfTheRamanEffect · Mar 26, 2018 at 06:47 PM
If you know the object you're executing the pointerEnter event upon, then you can simply call the following when you want your inputs injected:
ExecuteEvents.Execute(target, eventData, ExecuteEvents.pointerEnterHandler);
Where:
target = gameObject to execute the event on
and eventData = an instance of PointerEventData that has its relevant fields populated with your data
If you don't know the object you're executing the pointerEnter event upon, then you will have to do some raycasting (or query a raycaster) to find out where your inputs go.
Hope that helps!