x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 ?

Product Version: Not Selected
Tags:
more ▼

asked Aug 16 '14 at 08:58 PM in Blueprint Scripting

avatar image

TheTrice
112 22 21 29

avatar image S0T0 Aug 16 '14 at 10:30 PM

Call a custom event from inside the click function.

avatar image TheTrice Aug 17 '14 at 02:41 AM

Cant since it cant see the custom events of toher blueprints or level blueprint.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Hi there, I ran into this same problem and Have figured out how to solve it. Or at least one way of solving it.

  • Widget name is TestWidget

  • Event dispatched is called closeMenu

  • Image gallery is here on imgur

Widget Blueprint alt text

Level Blueprint
alt text In your widget blueprint, create an event dispatcher as you would any other. I called it closeMenu in mine.

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 :)

more ▼

answered Aug 18 '14 at 04:30 AM

avatar image

Bergasms
41 1 4 9

avatar image TheTrice Aug 18 '14 at 01:21 PM

Worked like a charm , but the problem is I didnt know about Event dispatchers , that will change so much in my game code , why wasn't this introduced in UE4 tutorials ??

avatar image Element457 Sep 08 '14 at 10:42 PM

I was just wondering the same thing! Great job, Bergasms! Thank you for your help!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Mar 25 '15 at 03:56 PM

avatar image

RumbleMonk
206 11 18 19

avatar image aadithyabk Mar 25 '15 at 04:33 PM

Thanks a RumbleMonk :) I'm new to unreal and I'm trying to figure out things. Really helps!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

@Bergasms, Can you please help me out here ? In the first image, I understand that 'Get On Clicked Event' is a blueprint function that you have created. But can you tell me what the third node with the envelope is ?

more ▼

answered Mar 25 '15 at 04:18 AM

avatar image

aadithyabk
11 1 2 3

avatar image Bergasms Mar 25 '15 at 05:53 AM

Heya, Bare in mind that this answer is from a couple versions of UE4 ago, so It might no longer be current.

Off of the top of my head, the node with the envelope is an event dispatcher. You used to be able to create them in your blueprints the same way you create variables and other stuff. An event dispatch is essentially just a message that can be sent out by the owner of the dispatch. So in this case, my Widget owns the closeMenu dispatch. when i call the dispatch (what is happening in the third node you asked about) the owner is essentially throwing the message out to whoever is listening for it.

In this case, my Level blueprint in the second picture is listening. Because the level blueprint created the widget (all the stuff in the second picture before the cast node) it has a reference to it. Once I do the cast node (middle of the second picture) my level blueprint knows that the widget is actually my custom widget called TestWidget. It also knows that TestWidget can send out a dispatch message called closeMenu so it can bind to that event and catch the dispatch whenever the test widget throws it out.

Hope that makes sense and isn't too verbose.

avatar image aadithyabk Mar 25 '15 at 05:57 AM

Thanks a lot! That really really helps.! So, is the node below SET the reference to your widget ?

EDIT-- Also, if you don't mind can you tell a word or two about the what the last node does in the first image ?

Thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question