Array of widget references refuses to fill

Hi, I’m at my wits end trying to fill this array of mine. I’m working on a drag and drop inventory system, and have been using this video series as reference:

So, I have an “inventory” widget, which contains a number of “inventorySlot” widgets. InventorySlots are simply buttons with an image on them, and this image is bound to a variable.
InventorySlot Hierarchy.JPGInventoryWidget Hierarchy.JPG

Now, in the ‘inventory’ widget, I want to make an array containing references to the inventorySlots, like so: (I made a custom event rather than using the event construct so I could call it whenever to debug)

However, when I try to access this array variable, it seems to be empty. What am I doing wrong?

Additional notes:
If I move the InventorySlotArray variable to a separate actor BP meant to hold the actual inventory and use makeArray there, the array seems to fill, but not with the correct values - i can print out the indexes and there are 10 - but if I try to print out the actual array elements, it prints nothing.

Hi ,

just a question ; where do you call “Make SlotArray” event ?

Thanks for having a look at my topic!

Well, I have tried several different places. The project has several different menus, with one of them acting as a “main menu” if you will, and the other menus being added to or removed from the viewport as the player clicks various buttons. I am currently making this array at the start of this “main menu”. The player can then click a sequence of buttons (selecting options) which goes through a couple menus before arriving at the menu in which this array of buttons is displayed.

Anyone have any idea on this? Haven’t been able to make any headway.

The problem is that you arent getting the elements from the first array. You need first to get the elements from the first array and then add it to the “InventorySlotArray”. For this to work you need to use “ForEachLoop” and “Add” node (the first picture inside the link). After that, do this: Like on the picture from the link plug the “InventorySlotArray” to the array input of the “Add” node and take the “ArrayElement” from the “ForEachLoop” node and plug it to the other input. The execution line that needs to go inside the “Add” node should be from the “LoopBody” of the “ForEachLoop”. :slight_smile:

Edit: This should be done only once, so its best to use “BeginPlay” event on the “ForEachLoop”, because if you execute the loop more than once it will always add the same elements to your array and it will become a huge array which you dont want. :wink:

Thanks for the help. Sadly, doing it that way made no difference. It’s still filled with null values.

Hmmm, can you test with getting the reference of the widget with “GetAllWidgetsOfClass” node and after that do the filling of the array with your way of doing? Too bad I dont have UE4 here…