Announcement

Collapse
No announcement yet.

Array of widget references refuses to fill

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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: https://www.youtube.com/watch?v=wyC5vl64V9k

    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.
    Click image for larger version

Name:	InventorySlot Hierarchy.JPG
Views:	1
Size:	10.8 KB
ID:	1187523Click image for larger version

Name:	InventoryWidget Hierarchy.JPG
Views:	1
Size:	21.6 KB
ID:	1187524

    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)
    Click image for larger version

Name:	InventorySlotArray graph.JPG
Views:	1
Size:	122.0 KB
ID:	1187528

    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.
    Click image for larger version

Name:	InventoryActor SlotArray creation.JPG
Views:	1
Size:	69.1 KB
ID:	1187529

    #2
    Hi ,

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

    Comment


      #3
      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.

      Comment


        #4
        Anyone have any idea on this? Haven't been able to make any headway.

        Comment


          #5
          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".

          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.
          Last edited by NasteX; 07-12-2016, 08:30 AM.

          Comment


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

            Comment


              #7
              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...

              Comment

              Working...
              X