Hiding a Widget

Hello there, I am having some difficulties setting up a skill system. I have some variables set up inside the widget, but it seems like each time I close and reopen menu all variables get back to their default values, which makes sense but I can’t get around it.

I assume this is because I am closing the widget completely deleting all variables; Is there any way of hiding it instead?. Please look as the screenshot provided and help me with sorting this out.

You can add or remove a widget to the viewport whether you want, in your case the values are resetting because you are creating a new widget every time. So what you can do it to promote the out value of Create X Widget to a variable. Each time you open your widget check if that variable is != to null or nothing to check if you have to create the initial widget or just adding it to the viewport. When you close the widget just remove it from the parent but to not null your variable. The only place where you would like to set the variable to null would be in the Destroyed or the eEndPlay events.

Apart from adding/removing it from the viewport you could also just change the visibility between visible/hidden, this requires that the widget is created only once though.

Hope I could help ^^

Cheers,
Moss

I’ll post a shot ^^ but you have to ensure to create the widget only once, if not all your variables will reset. Or you add an initialization event/function to set the required values when you make the widget visible.

Right now it doesn’t matter for me when the widget is created, I can even set it to after EventBeginPlay. But you mentioned visible/hidden functionality, how do I use it? Screenshots will be highly appreciated.

Oh well, I got it now. The ‘Remove From Parent’ funtion confused me, but I see it works just like remove from viewport.
Here is how I fixed it:

Thank you for help, problem solved.

1 Like