How to cast to widget

I’ve been looking around for ages for answer to this question and I was hoping you guys could help;

I have a widget that I want to cast to in another actor so that I can reference variables set in the widget but I don’t know what to put in the “object” node. I’ve tried tons of options but had no luck.

Thanks in advance all :slight_smile:

You could get the object references using GetAllWidgetsOfClass and pick the first (index 0) if you only created one instance of the widget.

To keep things simple my Actors don’t need variables from within Widgets. Widgets however do need to communicate with Actors sometimes like if a Button is clicked. Event Dispatchers can be used that gets called by the Widget (OnButtonClicked) that the Actor can bind to.

Instead of having to find the widget with GetAllWidgetsOfClass you should instead either save the reference when you create the widget or make all the necessary bindings when you create the widget.

I used a custom game instance (be sure to select it in projects settings or it won’t work). Make a var in it. Cast to your custom game instance and use that var in your other blueprints.

This is how I do it. GET a Copy is needed. No one really says that. They just say GET.

1 Like

Perfect! Thanks for your help

Actually, having had a look at this, this might suit my needs even more. Thanks!