Announcement

Collapse
No announcement yet.

How to cast to widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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

    #2
    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.

    Comment


      #3
      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.

      Comment


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

        Comment


          #5
          Originally posted by Odb718 View Post
          This is how I do it. GET a Copy is needed. No one really says that. They just say GET.
          Perfect! Thanks for your help

          Comment


            #6
            Originally posted by jay_adams_11 View Post
            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.
            Actually, having had a look at this, this might suit my needs even more. Thanks!

            Comment

            Working...
            X