[UMG] Issues with UI widgets carrying over between levels.

Currently, I have a system in which there is the Main UI widget, displaying score, time etc. which is added to the viewport at the start of a new level.

When the player loses or completes the level, a new widget is added to the viewport (End Level) with buttons for continuing to the next level, quitting to menu and restarting the current level.

When the player uses any of these, the EndLevel widget is removed from the viewport and the appropriate level is loaded - however, the Main UI widget is still displayed. Restart the level and the UI stacks on top of the old one and halves the frame rate.

I cannot find a way to remove the Main UI widget from the viewport when using the EndLevel widget.

Any help would be greatly appreciated.

You should use an event to notify the UI it needs to remove itself. Or when you create the main menu UI, you should store it in a variable on something like the player controller and call Remove From Parent before moving to a new level. Your EvenLevel widget could notify the player controller the level is ending to allow it to do any clean up work.

Cheers,
Nick

Thanks for the reply.

That worked perfectly; much appreciated!

Great work with UMG - not only is it extremely practical, it’s really fun to use.

For me Remove From Viewport worked insted.