Widget Switcher - change active widget index - not responding

Hello.
I´ve created a widget. It contains a widget switcher with 2 children (index 0 and 1) and a Button that reset Widget Switcher to Index 0 (This button is not child of the switcher).
Inside Switcher child with index 0 is a button that change active widget index of that switcher to 1, and it works as intended. I can click reset button to change index back to 0 and again click on Button inside a widget switcher to change it again to index 1, and so on.

Problem is, when i close entire widget via another button → Remove From parrent, and reopen widget again, button inside swticher child that supposed change active index dont work.

Debug: I print active widget index on tick, and durring error state it shows 0, even though print string on function that change widget index says index 1.

Another observation: after I close widget and wait a certain amount of time (several seconds), widget switcher works as intended. Until I close it again and that it breaks, again.

I wonder if this is a problem, after closing a widget, there is still reference to old widget somewhere in memory and I must wait for garbage colector to clear it.

I wonder if this is a problem, after closing a widget, there is still reference to old widget somewhere in memory and I must wait for garbage colector to clear it.

Sounds very much like it.

How do you do that? Are you creating a brand new widget every time - if so, is it intended? Would it make sense to reuse the existing widget?

Yes, I create new widget everytime a interact with object, that create that Widget.

Perhaps problem was in my hiearchy:
I’ve got an canvas that countain switcher and some buttons. Switcher contains child Widget (inventory), that child contains another child widget (Item slot), and that child contains another child (Button).
So I reworked my hiearchy and design and right now it worked great :slight_smile: