- Home /
Detecting onDrag over UI images
I have a Canvas with some Images children and all i want to do is:
on touch(or mouseclick) on an image, i want to store the image.tag in a list
on drag i want to store the image.tag if i drag over another image not in the list
on release i want to Debug.Log(tagsList) and clear the list
I know how to add clear and check if (list.contains), but i have not understood how to detect drags over images on a canvas, and in general how Touch input works. I've tried using IPointerDownHandler, IDragHandler, IPointerUpHandler on the canvas script and using a public Image[] trying to image.rectTransform.rect.Contains(touch.position) but it didn't work as aspected..
I'm sorry for my bad english, I can give more details if it can help :)
Answer by jterry · Jul 24, 2015 at 03:35 PM
You could use the eventData from OnDrag:
public void OnDrag (PointerEventData eventData)
{
Debug.Log(eventData.pointerEnter.name);
}