Assigning an image to button's child set in a container - Widget UMG

Hi all!

I’m trying to create a BP which will allow me to swap meshes, materials, color and additional functionalities I intend to add in the future, all contained in it.

I just can’t get my head around is how to expose a parameter to change image/text etc for each button added as a child to a wrap box.

So the idea is that I set in my actor blueprint the number of options for static meshes I want to swap, the number of materials/textures for each actor, change colors, etc and I think I can get there once I know how can expose the index/id and be able to assign an image to each child button created in the wrap box container.

I’ve managed to create the event dispatcher logic for each ID which is working great but I’m stuck on changing the freaking button image :man_facepalming:

To better explain it visually, here is what I’m at:

The Blueprint So far:
Part 1


Part 2

My Base button:

Its graph:

My container (wrap box):

Its graph:

The widget that I’m intending to have as container to switch widgets and the main buttons for each functionality. It’ll be the the widget set in the actor blueprint:

I hope it makes sense as sometimes I struggle to ask the right questions :sweat_smile: please, any help in the right direction is highly appreciated.

Thanks

You can set the Image Variable to be Instance Editable, like you’re already doing with the ID Variable.

and then pass the image to the button when creating it.

1 Like

Hi Arjun, thank you so much for your time and answer.

I exposed it and I thought I had an eureka moment but got stuck again :joy:

So I got it set in my Construct widget in the container:

Now I’m trying to work out how to expose it in my actor blueprint via an array, so each texture image index is assign to each button.

Should I use a for each loop or something similar?

[EDITED to add more context]

Create an Array Variable of type Texture2D in WB_EditMesh for the Images.

Create a new Custom Event, in the Event, Loop through the Image Array and Create the buttons, pass in the ID, Image like before.

in the Actor Blueprint, after casting the Widget, set its Images Array variable and call the Custom Event to make the buttons.

Since you’re getting the Widget Blueprint from the Widget Component and not creating it, we need to call a custom event to create the buttons instead of Event Construct. Because Event Construct will run before we set the Images Array Variable.

1 Like

Thank you so much for the help Arjun! :pray:

I was adding it after the construct, I guess I need to go for a walk to refresh the mind :sweat_smile:

Working beautifully:

Now I’ll work on the same principle for the other widgets :smiley:

Happy Holidays!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.