Slate. Custom button. Loops for constructing.

Hello. I’m trying to implement a button. In docs I see HoverImage, NormalImage so using my skins not a problem. Now I want to set background to my button - simple colored square for now. How?
Second question - how to use loops for content construction. For example, in this great Tutorial author creates 4 images by hand. I want to use loop for this, but code doesn’t compiles because of unacceptable syntax.

You want to create content in loop or create buttons in loop? If its the latter it would go like this:

// In construction code...

TSharedPtr<SHorizontalBox> Container = SNew(SHorizontalBox);

for (int32 idx = 0; idx < 10; idx++)

// other code ...

//Add container to actual child's slot



Above code will add 10 empty buttons aligned horizontaly. To make them vertical use SVerticalBox.

Hope this helps

1 Like

Sorry for thread necromancy, but didn’t want to make a new one for an additional question to the same topic.

How could I align the HorizontalBox in the above example using VAlign(VAling_Fill) and HAlign(HAlign_Fill)?
I tried different ways, but it seems that I don’t have access to alingment in Container, or did I miss something?

Nevermind…putting it after AddSlot() worked as usual