How does OnBeginDrag work?

I cant get OnBeginDrag to fire at all. I created a scene with nothing but a camera and a Canvas with a UI panel with the below script, and it doesn’t fire when I click on it then move the mouse.
public class ItemData : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler { public void OnBeginDrag(PointerEventData eventData) %|-1233518199_1|% Debug.Log("Beggining Drag"); %|1112063221_3|% }

I have no idea how this interface is supposed to work, the tutorial videos I have seen just add the interfaces to a script in the UI element and it just magically works. Does the panel need to pickup raycasts? What am I doing wrong?

You have to add the component canvas element to the object, and check the “stop raycast” toggle (not sure for the name but, something like that…)

That should do :slight_smile:

Do you have any UI component attached which can receive raycast (toggle on)? For example, an Image or Text.