Controlling of widgetvisibility with another widget

Hey guys,
I´m trying to make my inventorywidget visible with another widget(the upper left one button) for a mobilegame.
I dont know how I can cast from the buttonwidget to the inventorywidget, I tried pretty much and couldnt find something in the internet, I`m pretty sure I just need the target on the cast, then it would work.
Thank you for your help :smiley:

I think that you just have to add another widget to your viewport on event button clicked. Just make :
Event Button Pressed - Create Widget (select your new widget class with your inventory)-take the return pin from that and call -Add to viewport and set Z value greater than the widget you are putting it on like 1 if your first widget‘s Z value is 0. To delete it just call a remove from parent node in your inventory widget when you click the cancel button in the inventory widget.

Yeah that was the first thing I tried, but then my Inventorywidget gets reloaded with all the item I collected before destroyed :confused: Because I would basically delete everything I saved in the Inventoryvariables/arrays and just load it new the next time I would add it to the viewport, thats why I need to hide it/make it visible with that button, it needs to be active all the time

Well then why don‘t you combine the widgets into one where your toggle button is placed at your desired location(upper left corner), and the rest- pack it together in one overlay widget component (see left side widgets components.) Them what you do is animate your overlay components alignement or something like that. So: create a new animation „inventoryshow“. Add the Overlay Component and do a timeline where your last location is OUTSIDE OF THE VIEWPORT. On button click it will animate this and the overlay is hidden outside the viewport. Play the animation in reverse after toggling the button and your overlay with all the variables slides in cause you did not destroy your widget. If you have tondestroy it later on better save your variables in game insatnce.

Conclusion: Pack in overlay-create animation-animate outside viewport(and animate in)

That is a pretty awesome idea, thank you man :smiley:

What you do is, you go the the BP that “creates” the widget and right after you create it store the output as a reference variable. Then when you want to access that widget you cast to the “Creator” widget and grab the reference of the widget from that BP. Below is an example of this:

  1. Player Character BP creates Widget A
  2. Player Character BP stores a reference to Widget A
  3. Widget B would like to modify Widget A’s properties but must get a reference to Widget A first
  4. Widget B casts to Player Character (the object pin of Player Character is easy to reference by “get player character”)
  5. Once Player Character is available drag off the output pin and ask it to “get” the reference to Widget A
  6. Widget B now has the reference to Widget A through the Player Character
  7. Modify Widget A from within Widget B as you see fit!

Hope this helps!