Download

Slate, how to have space between buttons in SVerticalBox?

I am creating my menu via slate and want to put empty spaces between buttons.
I try to do it with SSpacer.
I do not know, if SSpacer is the right choice here.
The following code is just not working, changing of the size of the SSpacer
does only do something for really large values, then the UI is completely broken.

How do I put an empty space between the buttons?



					SNew(SVerticalBox)
					+ SVerticalBox::Slot()
					
						SNew(SButton)
						.ButtonStyle(&m_pMenuStyle->MenuButtonStyle)
						.TextStyle(&m_pMenuStyle->MenuButtonTextStyle)
						.Text(FText::FromString("menu item 1"))
					]
					+ SVerticalBox::Slot()
					
						  SNew(SSpacer)
						  .Size(FVector2D(0.1f, 0.1f))
					]
					+ SVerticalBox::Slot()
					
						  SNew(SButton)
						  .ButtonStyle(&m_pMenuStyle->MenuButtonStyle)
						  .TextStyle(&m_pMenuStyle->MenuButtonTextStyle)
						  .Text(FText::FromString("menu item 2"))
					]
		


Add padding to your buttons.

Could you elaborate? I only find ContentPadding, and that is inside the button already.

is this the right way?

Indeed, the padding goes on the slot. You only need bottom padding if you want to space out objects in a vertical box, obviously.

Thank you very much.