Download

How can I change where I must drop an item to drop it from inventory?

Hey Guys,
I have watched the official tutorial series for inventory and drag&drop: https://www.youtube.com/watch?v=wyC5vl64V9k

But I have a little problem, if I want drop an Item from Inventory, I can only drop it in the Inventory, if I drop the item outside of the inventory, nothing happens…
Maybe it´s the problem, because my inventory has no slots, only a wrapbox?

How can I make it now, the item should only be dropped outside of the inventory and not inside?

There´s a video of the problem:
[video]https://youtu.be/g3c-k_u_zas[/video]

Would be nice if anyone can help me now, after not only one tried to help me in my last threads…

So when the drag and drop operation fails, the items are instantiated, it looks like? That what it seems like. In order for it to not fail, you need to make it succeed. So whatever element you want to drop on needs to have an on drop function.
So since you want to drop it on the “inventory space” as I will call it, (as opposed to a specific “inventory slot”) that inventory space will have to be its own widget with an on drop function.

Thanks,
but if I want drop it in free space and not on a widget?

I think I want recreate my inventory with slots and not with a wrapbox (like now), should be easier, because Jat did it without a wrapbox, too^^

Not sure what you mean by “free space”. If you drop it not on any hud elements, they spawn in the world in the video. If you drop it on the hud element that appears to be the inventory space, they also spawn in the world, but you want it to be put in the inventory, right?
You need to make the “inventory space” catch the On Drop event. I don’t know of a way to make an element (such as the wrapbox, border etc) do that, the “inventory space” would have to be a widget class with an On Drop event (in this case, it would be a widget with just a wrapbox).

I can think of mainly two ways to do it:

  • Create an inventory widget which has the On Drop event. This widget will also hold the “slots”, a slot is a widget with its own On Drop function.
  • Using the overlay, have an invisible widget *under *the “slots” that receives the On Drop event.

I did it now in another way, no drag and drop anymore if I want drop an item, there´s a button to drop the clicked item and change the dropped amount^^

The way I did this was to setup the main HUD widget (that contains all of the individual widget elements) with a canvas panel that receives drag and drop events. On Drop, if the item is being dropped on the main hud, it will prompt for item drop or delete.