The most minimal way to get dragging working on a custom UI element?

desukarhu

Member
Hi,

I'm using UIS for abilities and when the player gains a new ability I'm showing a popup that says stuff like "(name of ability) unlocked!" and a icon of the ItemInfo that was unlocked (unlocking is done via a bool attribute).

What I need is to make the icon draggable like UIS ItemViews so the player can drag the ability straight into their hotbar, but since it's just a single ItemInfo I would like to keep it as minimal as possible. What would be the best way?

Thanks
 
The drag and drop system uses the default Unity UI interfaces: (IPointerClickHandler, ISubmitHandler, ICancelHandler, IBeginDragHandler, IEndDragHandler, IDragHandler, IDropHandler)

This is done on the ItemViewSlot component. The ItemViewSlot relays that information to the ItemViewSlotContainer. And the ItemViewDropHandler component listens to the event triggered by the ItemViewSlotContainer. That's how it know when a drop happens.

You have two choices either take advantage of ItemViewDropHandler system. Or instead create your own component that listens to the ItemViewSlotContainer.HandleItemViewSlotDrop event.
 
Top