When is the OnDrop method called? IDragHandler

I have a UI Inventory system already created. When I drag and drop an inventory item up to an Image UI (image of the character) it fires an OnDrop method and equips it. But if I drop the items elsewhere than this one does not execute any OnDrop method.

How does IDragHandler recognize an area where you can run OnDrop?

PS: The image does not have any attached script.

Please help me!!

As far as I know, the Handling is done with raycasting, in this case graphic raycasting. Your image must have “Raycast target” enabled, and you didn’t even need to enable it as it’s enabled by default when you create an UI → Image gameobject.

You can make it have the same behaviour (triggering the OnDrop) if you add a graphic raycaster component to an object it does not work with. Even a physics raycaster would work (I use it for touch to location commands, for an example).