4.7.2 Can't Remove or Hide UMG Button

Hi,

I’m trying to create a button on th

e HUD that can appear under certain conditions and is then removed after is is used. However, no matter what I try, the button will always be visible once made visible.

The Blueprint controlling this is in the Player Character Blueprint. I’ve tried setting visibilty to be hiddeen, and I’ve tried removing it from its parent and neither work. This is both on my PC (laptop with GF 485m) and my NVidia Shield Tablet.

To test this more quickly I’ve set up a simple Blueprint which toggles the visibility of the button using the B Key and added a screenshot of it to this post. I’ve left the ‘Owning Player’ blank as this seems to work and adding a ‘Get Player Controller’ or ‘Get Player Pawn’ variable here doesn’t make a difference.

Is it ok to do this from the Character Blueprint, should I be handling this another way or is this a bug?

I had to modify some of my stuff temporarily, so ignore the excess stuff in the images, but try this:

Overview: You have a variable that exists and can be changed in a character bp, a widget bp casts to the character bp to access that variable, and based on that variable the widget will change the visibility of its component(s).

1.) Create a button in a widget blueprint
2.) Click the binding drop-down next to the visibility option in the designer tab (not event tab)
3.) In the drop-down bar, click create new binding and name it something that has to do with visibility. This is a function, and you can also use this for other elements in the widget too if you want. (In my picture, I use “stage 1 visibility” as the same binding for multiple buttons/borders/fill-bars/etc.)
4.) Stop doing stuff in the Widget bp, and open up your character bp and make some boolean variable.
5.) On “Q” or whatever, make the boolean true when pressed, and off when not pressed. This will make the button appear when you press and hold Q.
6.) “Create Widget” and “Attach to Viewport” in the character bp for the widget you’re using.
7.) Return to the widget and cast to the character bp to access the boolean value you made. (This can either be done in the function, or at construct like in my pictures and you simply save the character reference. Both work.)
8.) Drag from the input pin of the function return node to create a “visibility” variable, and use the boolean from the character blueprint to change the visibility variable’s value.
9.) Make sure the button in the designer tab has the binding set to your function…

Widget Event Blueprint (above)

Widget Function Binding

Character Blueprint

Widget Blueprint (Designer tab)

Thank you. And how should I be handling deleting this Widget or removing it from its parent?

I currently have slightly different UIs for Touch, Mouse & Keyboard and Gamepad.

I’ve now got the visibility working on my PC, but the button is never appearing on my Android Shield Tablet.

I’ve got Print Screens firing every tick within the Event Graph of the Widget and whenever the Button is being set to visible. These appear as expected on the PC, but never on the Shield. I’ve checked the cooked folder and the Widget’s Uasset is present. Any ideas?

Sorry was out of town yesterday. Yeah Android has been weird with widgets. My 3D widget component with “world” space setting is upside down and backwards; however, my UI widget that I attach to the viewport works, so your button should work. Also, I’m not sure if print screen works on android, I tried printing on my phone and it never popped up so you may have to have another form of debugging. If you could provide me some images of your current BP setup for making your UI work I may be able to help with that.

Also, try launching your game to your tablet by clicking the drop-down menu next to the launch button and selecting the “launch manager” option. With your device connected, change “Developement” to “Shipping” and “On the fly” to “By the Book” next to the android launch button. You may also want to change the build to whatever you’re supposed to use for the shield (like ETC1 or ETC2, etc.). This may not help, but its fixed some of my problems in the past. Plus it’s faster than packaging and installing.

To delete and remove the widget, drag a line from the create widget node and type in “destroy”, that will give you a destroy node to get rid of the widget. If this creates clutter just make the output of create widget a variable so you can destroy it later.

No problem. Just to confirm, ‘Print Screen’ does work on Android. It looks like nothing in the Widget Blueprint is functioning.

I have had the buttons working before on Android, but that was when the button’s default appearance was ‘Visible’ (they’re currently hidden) and I added the visibility bind as described above.

There’s a seperate bug at the moment on Shield that doesn’t allow you to set which textures the Shield will build with, but it defaults to the correct setting anyway.

I’ll try out your suggested changes, and if none of them work then I’ll go ahead and print some screenshots up.

Ah ok good to know, maybe it’s just a quirk with the Note 4 then. If the buttons work when they are initially set to visible, then try having everything set to visible to start and then just hide them with a begin play node.