Download

Having issue with 'Cast to' between two UMG widgets.

Hi, I’m having an issue with communication between multiple UMG widgets. I maybe doing this completely wrong any help in any way would be amazing.

What I want to do is have one master widget with 3 sub widgets inside it, and have buttons within sub widgets be able to change the set visibility within the master widget. The master widget looks like this:

Question-One.jpg

https://youtube.com/watch?v=BdARbvNrvQE
Using this tutorial on “cast to” between UMG widgets, I’ve made some progress but I’m stuck. this is what I have so far:

Here’s my hub blueprint:
Question-Hud.jpg

Here’s my widget1 blueprint:
Question-Widget-One.jpg

and here’s my function within the master widget:
Question-Function.jpg

Right now I when I hit the “widget 1” Button I would expect “widget 2” to become visible and print the string. But the only thing that happens is the string prints, no visibility change.

Any help on what I’m doing wrong or a better way to do this would be very much appreciated.
Thanks!

In your HUD screen shot you are doing something very weird. You create a viewport widget initially of type “BP Layout”, then you also have a 3D widget which you cast to “BP Layout” and that is what you set as the reference for the BP_Layout used in you button click event for widget 1. So you are using the viewport widget for the button click and having it find the 3D widget to actually do anything. So I think what is happening is that your BP_HUD which has a 3D widget attached to it somewhere (not even sure how that is working honestly) is what is getting its visibility toggled not the viewport widget. Delete the 3D widget (the whole user widget object stuff) and instead store the viewport widget (the one you made using the “create widget” node) as the Layout Ref variable instead. I am not sure why you have a 3D widget on a HUD BP anyway, it is unnecessary.