foreachloop in umg inventory

Hello…
I’m trying to build a small inventory widget, where you can pick up objects, like notes, books n stuff
and get a picture and some text in an inventory. it kind of works, but i ran into a problem.

my setup is that every time you pick up an object it gets added into an “inventory” array and the pickup function
then calls a custom event to refresh the inventory widget to add a button and text to the inventory.

my problem is that the refresh event doesnt just create one button for the new item. but it does so for all items in the array (well yeah, the way i did the blueprint its kinda supposed to do that, i get that), so every time i pick up a new item it adds buttons for all items in the array duplicating to the already created buttons.

now my workaround was to take the output of the completed pin (of the foreachloop) and set that to the create widget button, it kinda works, but i don’t know if thats a good idea, also it now recreates the whole array everytime i pick something up, right? performancewise i wanted it to just create one additional button for the one item i picked up and keep the item buttons i picked up before. would that be a better solution?

does anyone has any idea how to set this up properly. help would be highly appreciated :slight_smile:

I’ve ran into a problem with this again.
I made a save system, which saves the inventory array. But because in my blueprint for the inventory system,
I could only manage to use the completed output of the foreachloop, when I load, only the last item in the array gets displayed. I know, the way I set it up, its supposed to do that, but I want to change that somehow. So could somebody give me a hint how to properly set this up. I mean just the foreachloop in the widget, not the savesystem (that works as intended).
So that I can use the loop body output instead of the completed, but not have it duplicate every button for the items that are already in my inventory array? please help…

I managed to get it working.
now if an item gets picked up (and placed into the inventory array) the last item in the array gets a new button (by the refresh inventory event, that gets called by the pickup function), without a foreachloop. and when i load a savegame, the whole inventory gets rebuild from the saved inventory array (load inventory event, called by the load function) with a foreachloop. working nicely.