Download

A little help with Event dispatcher

hi friends, so again I am in trouble with Even dispatcher, which after all my efforts i fail to understand.
So i have a widget “main_ui” and i have a blueprint “blueprint1” . the main_ui has a button that i wish to press and something will happen inside blueprint1. the main_ui is loaded through level blueprint and blueprint1 is put directly into the scene. i have called an event in main_ui “event1” . now in blueprint1 when i bind this event1 it needs a target but how do i get the main_ui into blueprint1 to plugin as a target in event1, sure i could do it if i create the widget inside blueprint1 instead of level blueprint but that is not what i want. i hope i made my problem clear. any suggestions?

You shouldn’t put your UI in the level blueprint, put it in the player controller or something that always exists. Create the UI in the player controller and save it as a variable. Then in blueprint1 when binding you can Get Player Controller, cast to your custom player controller BP, then you can Get the UI variable reference.

thanks, i shall do that.
but just for my learning, is there a way to get that widget reference in blueprint1 without “create widget”?

If you’re not creating it somewhere, does it exist? You can use Get All Actors/Widgets of Class but it’s slower performance wise. In blueprint1 you don’t need to create it again (do it in player controller or whatever) so you do what I said above: Get Player Controller, cast to your custom player controller BP, then you can Get the UI variable reference.

Thanks cyaoeu for your help. :slight_smile: cheers mate.