I’m trying to have the OnDrop function called after a draggable image is dropped. To achieve this I have the following structure :
An image A with a script that implements IBeginHandler, IDragHandler, IEndDragHandler
An image B with a script that implements IDropHandler and of course an OnDrop function with a simple Debug.Log inside it.
When I drag my image A, all corresponding functions, OnDrag,OnEndRag etc. are correctly called - But when I dropped the image above the Image B the OnDrop function is not called.
Is there something special to set-up in order to have it worked as expected ?
I think to get any of the drag handlers in a script to work you have to also use IDragHandler, so even if you just wanted to implement OnDrop for image B it still has to also implement IDragHandler so it exists in your script.
It’s not quite obvious to add it when you implement drag & drop because there is no reference to it in the documentation when you look at all Drag and Drop related interfaces. You have to check-out the Drag & Drop demo scene and then in the DragMe.cs script you can see it.
Glad you got it sorted! This one took me a while to figure out too.
I’m not sure why OnDrop doesn’t propagate through the image being dragged automatically, it seems this is the most common use case for OnDrop. Maybe it will get switched around in a further update.