Move All Items after one of the Items was used. Using strictly grid panel.

Is there any way for a grid to have the same look as a wrap box when an item disappears all items from the right go to the left (Or dynamically go up) so that there is no empty space in the middle of the inventory?

Capturar

You’d need to manually move the 2 items in the upper right to their new respective columns.


Are you trying to avoid the WrapBox because you want to have a fixed 6x5 grid? If so, consider using it but add an empty dummy widget at the end once something from the middle is removed.

Thank you very much for answering. I’m working with indexes here. I was thinking of finding empty indexes (Find array) and relocating all items within the inventory array into a new index that was empty. How do you think I could create this code to relocate all inventory items. I use, for example, a code to find empty indexes and add an item to the first one that appears.

I use, for example, a code to find empty indexes and add an item to the first one that appears.

That could work but, rather than relocating, I’d remove array indexes that you do not need, this will shrink the array. Pad it to max desired size and use it to rebuild the inventory.

Yes! it works perfectly this way. all slots go to the correct side. Now I just need to make the slot refresh at runtime. As well as the thumbnail and item quantity that are already updated while I have the inventory open. I remove the index slot and only when I reopen the inventory does it load correctly because it’s already built in event pre. Any idea?

You could probably re-use the same script you have in Pre-Constuct. Ensure the slot has fresh data and fire a custom event executing the same stuff that the pre-construct executed.

solved! I had positive mental attitudes towards your ideas. We reached a satisfactory verdict. I did the following:

I removed the index from the inventory array, removed a widget from parent and just re-opened the inventory with the create widget function. Everything works really fast and all slots are updated instantly:

I’ll update this post if anything changes so that more people can solve this problem with grids. Thanks a lot for your help!! :grin: :pray:

I just noticed that some items I pick up don’t appear correctly. They are kind of hidden inside the array. I will find out…

So… I made some discoveries that I concluded a little bit per hour. I found that this actually doesn’t happen:

What happens is that my scrollbox was not far enough to the side. Only that. It was hiding the rest of my slots. The whole code I posted here works 100%. I just had to modify the scrollbox offset for it to recalculate the position I was consuming the item for it not to go back up.

I’ll update this post if anything changes.