Remove from Parent not working in Construction Script

Hi. I’ve a UMG which does some preflight checks in its construction event. If the are not met I show another widget and want the current widget to disappear.

So the flow marked as NOK is coming from the construction event and - does nothing, and yes it hits the remove from parent which I breakpointed
The Flow coming from OK is a simple Button press - it works like expected.
So my Question - is remove from parent not possible in construction script at all?

Hello Adnoh,

This should be working, I’m assuming you mean that you’re calling it on the widget’s “Event Construct”. This should cause it to be removed. What is this widget’s parent? How are you adding it to the viewport? Could you show the rest of the blueprint?

Hi Matthew, thank you for your response.I’ve worked around that issue but I try to reconstruct.

The logic where the problem happens is the following (all transition events are from my gameinstance):
Game loads, checks for savegame, if none shows optionsmenu, if i press “back button” (without setting/saving userinfo) it goes to mainmenu, in mainmenu construct it checks if the userinfo is valid, if not it should remove itself from the viewport and show the options menu again - this is not working and the part of my screenshot above.
if I press a “options” button in my mainmenu - this is the flow marked with “ok” in the screenshot abobe - it works like expected-it is exactly the same part which does not work onConstruct.

But I’ve realised two things: I get a warning after playing that the widget optionsmenu was allready added to the screen- this seems to me that its “remove from parent” has not worked, too [4].
Second, I see a lot of warnings in my log for example “LogConnectionDrawingPolicy:Warning: Looks like a wire-trace was not injected before the jump from 'Remove from Parent” - I have no Idea if this is only “engine-debug-stuff” I can ignore.

I’ve double checked the flows and it hits the “remove from parent” like I expect it! In the Options menu, in the main menu … but it seems not to execute it when not triggered by the user via button press.
Am I missunderstanding “remove from parent”? Is it not allways correct if the widget was created via “create widget” and “add to viewport”? Can I debug the stuff hirarchily which is on my viewport or whats the parent of my current widget?
121870-

Interessting - if I wrap it into a timer it works! Even with a delay of only .01
So the timer does the “remove from parent” and “show options menu” short after onconstruction and everything is fine!

1 Like

Thank you for that information. From what I understand, it would likely be better if you called Remove from Parent after calling Show Options Menu, as Remove from Parent is deactivating this widget. While it does keep it in memory, it shouldn’t be executing more after this so Remove from Parent should always be the last thing to be called. I’m thinking that the timer you spoke of causes it to keep executing despite this which would explain why that works.