Give current touch index to UI element

Hey, so im kind of strugguling with this. I want so whenever i touch a UI element to give him id of the finger which touched the actual UI so i could keep track of its phase. Any ideas? Would really help! :slight_smile:

-Thanks!! :slight_smile:
-Cheers!

if you’re implementing one of the eventsystem interfaces (IPointerClickHandler for example) touchID is

http://docs.unity3d.com/ScriptReference/EventSystems.PointerEventData-pointerId.html

eventdata being the parameter passed into the function

1 Like
[RequireComponent(typeof(RectTransform), typeof(EventTrigger))]
public class InputListener : MonoBehaviour, IPointerUpHandler {

    public void OnPointerUp (PointerEventData eventData) {
        //Check that the pressed object can receive the id
        if (eventData.pointerPress.GetComponent<YourUIComponent>())
            //Send it
            eventData.pointerPress.GetComponent<YourUIComponent>().DoSomethingWithPointerID(eventData.pointerID);
    }
}
2 Likes