How can I add an image (Texture) to a scroll box using "for loop" or "array"?

I have a scroll box where I need to load textures, but creating a bunch of widgets with separate textures is inconvenient and impractical. So is there a way to somehow add them via “for Each loop” or “array”, or any other ways to just load the texts and then load them into the widget via “add Child”?

For sure! Create a widget WBP_ListItem and set it up with a texture. Expose the texture as a public parameter

In the widget with the scroll box or list view build an array of textures. Then a foreach loop that
-Create widget WPB_ListItem
-set the texture
-calls add item on the listview

That should do it!

1 Like

Thx.


I completely forgot about the code, what to do with the code that is in WBP_ListItem?
How do I change the index (Red) in “Load Skin” and also change the material that will be set to " Set material "(Yellow), and so that another widget appears (Green)?
I’m sorry, I should have warned you.

This is scope creep!! Haha, You could create a function that takes in the index and material you want and set them to variables. Then call that function when you make the widget.

Modifiy the code here to use those new variables.

You can also adjust your texture array to be a struct with the index and material.

As for the on-click widget that should show.. doesn’t look like there is anything unique. Although there could be by repeating the process in that blueprint.

1 Like