- Home /
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!!
I would like to add an image like a trash can, if you drag an item down there, discard that item!
Please help me
Answer by TheSOULDev · Aug 08, 2017 at 10:00 PM
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).
Your answer
Follow this Question
Related Questions
UI drag and drop 1 Answer
How to move UI image between panels 0 Answers
Prevent Drag button inside scroll rect 0 Answers
How can I drag a project tab item out of all folders? 1 Answer
Help starting a card app 0 Answers