How to call functions from UMG?
So when i used to create buttons using actors , i would just have on clicked event in my level blueprint for this actor , and then i would be able to call all events i need in my game , but using umg i binded one of the buttons to an onclicked event , but in the function blueprint i don't have any access to any function so what i am supposed to call ? i cant call events from level blueprint nor functions from my actors in the game!? so is there a way to do this ?
Hi there, I ran into this same problem and Have figured out how to solve it. Or at least one way of solving it.
In your level blueprint, or wherever you launch your widget, make sure you get a reference to the menu. It will be a variable of type UserWidget
Once you have this reference, you can cast it to your widget, in my case this was called TestWidget. Drag off of the 'as Test Widget C' anchor and call the 'Bind Event to closeMenu' function. Where closeMenu is whatever your dispatcher is called.
Attach a custom event in your level blueprint to the bind event call, and then have that even do whatever it is you want to do. In my case, it just prints out a string saying 'clicked'
Hope this helps :)
The 'Menu' is indeed a reference to the widget. As of UE4.5 you don't need the 'cast to' node anymore as the widgets come pre-casted. :)
The last node in that first image, the return node, is what is expected in all functions. When you bind a text widget your return node will have a variable of the text data type so that you can plug text right back into it etc.
answered Mar 25 '15 at 03:56 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here