UMG is disappear when I get it from code

Hi. I made UMG Manager and Event Manager. Conversation widget is ok when I open it first time. But it is disappear when I call my function that get conversation widget from TMap that save UMG. I suspected my widget first, but there is no problem about widget. I think it is relative with code. But when I get conversation widget, there is no error and conversation widget is not null pointer that get from TMap and The pointer is same when I save to TMap and when I get from TMap in EventManager. Here is my symptom and code. What am I miss?

It doesn’t look like you’re storing your new widget in a persistent variable anywhere. I think it’s being garbage collected.

Thank you. your answer. I declare TMap that contain widget at UMG manager that declared in gameinstance. as I know gameinstance Is singleton, Am I lost my widget? even I declared tmap in game instance.

Your “LoadWidget” method doesn’t retrieve an existing widget from the TMap, it creates a new one. Are these the only two methods involved? You’ve only shows the .cpp code for two methods, and I don’t see anywhere that you’ve stored the created widgets in anything.

Is the behavior of the “ExecuteEvent” method as expected? If not, how is it wrong?

What function is called when the widget disappears? Does it go away at the same time consistently, or does it happen at different points?

I save conversation widget at ABaseHUD::OpenWidget when it called fist time. The widget is saved at ABaseHUD::_WidgetMap. When conversation event start, event manager get conversation widget and add AEventManager::ContinuEvent to conversation widget’s delegate. Then player click widget’s button. button will call ContinuEvent, ContinueEvent get conversation widget again from ABaseHUD. So When I check it I found saved widget pointer and widget pointer I made is same in ABaseHUD.

Thank you. I found my logic error.