Widget_Blueprint UMG problem!

Hey!

I have a little problem on my widget blueprint.
i want to be able to click on several material that i can pick on my palettes that it will show up on my viewport. I want to be able to change the material on the cube each time i fire a btn on my widget.
Here’s some screenshots… By the way the cube is a blueprint actor(primitiveComponant).
9af016beaca23030a6e822faa59790391cbfe134.jpeg

And this is what i’ve done so far… i probably miss somethings, because it is suppose to work… i think
I’m really don’t sure the function is good though.

Someone can help me out!?

Oh come on. Plz someone!

I’m honestly not sure how you’re accessing the TemplateCubeRounded from UMG.

To do what you’re describing, I’d probably try creating an event dispatcher in your widget, and on begin play in the cube bind the dispatcher to an event that fires whenever the button in the widget is clicked to set the material on the cube. You could add a material variable in the dispatcher that passes along a material reference form the UI if you wanted it to work with an arbitrary number of buttons or materials.

Honestly, I know very little about dynamic material instances, so maybe what you’re doing should work, I just don’t know how.

Thanks Stackbug

I don’t know anything about dispatcher :frowning: I’m trying to understand and apply what you just say to my project but… i didn’t know now what i’m doing :frowning: That’s frustrating!

MakeDispatcher.JPG
f615d0a012282c60dc2c567925cd03b237b9a9bd.jpeg

In the UMG HUD: create a dispatcher
On Button Press: Call that dispatcher
On Begin Play in the Blueprint: cast to your UMG HUD, and create an event binding to the event you created. From the “event” connector on the Bind Event action, drag out a connector and choose “add custom event for dispatcher”

Whenever the event ThingsHappen (in this example) is called, the bound event will fire. Since I want it to refire, I just run through the binding logic again.

Humm… In this exemple what is representing the Bp_RiverHud and your UIWMainHud (is this your Widget blueprint?) ? Also, how can i get the (target UMGHUD) you have between the cast to BP_RiverHUD and the Cast To UIW_MainHUD ? Because i tried to replicate but don’t no how.

Thanks for your help!

BP_RiverHud is my HUD blueprint. It’s where I’m managing the spawning of widgets.

UIW_MainHUD is the master UMG HUD. When I create it, I add a variable to BP_RiverHud called UMGHUD that I use to access it.

The specific casts are unimportant. You just need to cast to your HUD, where ever it was created, and use the cast to get the dispatcher.

Alright! It work now… not like in your exemple but it give me some hint. I managed to make it work without casting anything, just binding work well. Thanks Stuckbug for tha help! :slight_smile:

Now, Each buttons is binding different materials on my object, but i want to be able to click randomely on each button, but when i click on my button once, it work well, but when i clicked on another one i can’t go back on the first button.

Hey nice! I’ve been trying to figure out this same problem with you in a separate post, but had no luck. Can I see how you set yours up with the binding? I’m still learning blueprint and UMG too.