4.5 UMG Remove From Viewport not working in Widget

Create new UMG Widget. Add one button → create clicked event. In this event Remove Widget From Viewport (self)

It isn’t working.

Basically remove from viewport isn’t working inside Widgets.

Hello

I was not able to reproduce this issue. I would be more than happy to assist. I have drawn up some instructions to try and resolve the issue or at the least make sure that we are on the same page. Here is a list of things your will need.

  • A Player Controller
  • A Game mode
  • A Widget Blueprint

I hope this helps.

Cheers

I’m having the same issue…

When I click on either button it executes the command but does not close the UMG widget.

Hello TorQueMoD,

Are you adding the UMG widget in your player controller or character with the begin play node? If so this means that every time the level is changed the character “begins play”. This will cause it to seem like the widget was not removed. If this is the case then try adding the widgets that need to be visible when the level starts to the screen through the level blueprint. I hope this helps.

Make it a great day

No, I’m adding the widget through the HUD blueprint. Its called in two ways. Through a button press (Tab) and through a win condition (presented with the “you win” screen". Its only set to be removed either through the widget itself (when you press a button) or through the flip flop of the Tab key. The above example is showing the Widget’s blueprint.
Here’s a link to a larger image: http://torquemod.com/remove_from_viewport.jpg

And here’s a look at how I’m calling the widget:

Did you try removing widget from viewport before opening level?

Hello TorQueMoD,

Is it possible the “Add to viewport” node is being called more than once? This could cause it to make an exact copy of the widget and place it over the first. This second copy will then be only one being referenced by the buttons. So in effect you would be removing and adding the widget but there would be a copy under it that has lost it’s references. One easy way to check this is to set the alpha for something in your widget and see if it gets darker. I hope this helps.

Hello TorQueMoD,

Is it possible the “Add to viewport” node is being called more than once? This could cause it to make an exact copy of the widget and place it over the first. This second copy will then be only one being referenced by the buttons. So in effect you would be removing and adding the widget but there would be a copy under it that has lost it’s references. One easy way to check this is to set the alpha for something in your widget and see if it gets darker. I hope this helps.

I don’t believe its being called twice. These are the only two ways its called and they’re both in the HUD blueprint.

@anonymous_user_5884154f - I’ll try changing the order so its removed before loading the level and see if that fixes anything.
Just working on some models at the moment so I’ll try in a few hours.

So changing the order of the remove from viewport and open level commands didn’t change anything. I did however change the transparency of one of the buttons and its not transparent which leads me to believe that it must be doubling up the widget. I can’t figure out why that’s happening though since its only called in the HUD blueprint. I’ll keep playing around.

Ok I think I know what’s happening… I’m calling the Widget via the “Event Receive Draw HUD” node which is making the Widget constantly show. As soon as I removed that call and only left it on the “Tab” key it fixed the problem.
Is there a way to fire a keypress automatically even if the user doesn’t press it? Then I could just have my “Win Screen” press Tab and the screen would come up automatically.

Hello TorQueMoD,

You could cast to the blueprint containing the Tab key and just run the event that triggers the “Win screen” straight into the flip flop (tab and this event will be running into the same flip flop).