Add Child To Vertical Box not working.

Hello and thank you for taking your time to help me.
I am trying to make an inventory. The problem is that the Add Child to vertical box does not seem to work.
Here is my code:

All the code snippets shown are executed, all the Widget used are displayed (opacity of 1 and visible), the widget to display is not in a canvas panel. I have already checked many topics, none of them gave me a solution.
Thanks in advance !

How do you know?

Widget used are displayed

Going by what I can see. You create the inventory widget but never do anything with it. You say it’s not in a canvas panel. How do you show it then? Where / when do you add it to the viewport?

Also, since you create the inventory without referencing it and then proceed to destroy the actor, this widget will be destroyed by garbage collection as soon as it loses a parent container. And since we do not even see how it gets to the viewport… it may as well get destroyed immediately.

Yes, indeed I have forgotten to talk about this. I add the inventory widget to viewport when pressing Tab in my player blueprint. The code snippets are executed because I verified it with some Print String. To clarify, the Inventory Widget has a Canvas Panel but not the Widget Item Widget. Finally, the actor destroyed is the item and the Inventory variable is stored and referenced in the Inventory widget, which never gets destroyed. Since the ItemType variable is added to the Inventory array, even if we destroy the actor the information should remain, right?

I also forgot to specify that all these parts of code of the image were not part of the same file, it is an assembly of several different files

I apologize for the lack of clarity in my message

It still does not add up. Where do you add this widget to the viewport?

It’s not referenced, there are no other wires coming from the return pin, it’s not being added to another container either. Every time you call the above, a brand new widget is created. If you attempt to update the inventory 5 times likes this, you’ll have 5 different inventories with 1 item each.

You also say:

I add the inventory widget to viewport when pressing Tab in my player blueprint.

How come? The inventory is created here in the screenshot above.

Could it be the case that you think that the widget in the Player BP and above are the same widget?

How do you access it in the Player BP with Tab? Get Widget of Class?

Ok I understood my error, as you said, I was creating a new widget everytime. Sorry for not understanding what you meant, thank you very much for helping me.

1 Like

Did you get it to work so quickly?