How to set SButton fixed size Width and Height (not padding)?

[FONT=Helvetica Neue]How to set SButton fixed size (not padding)? I need Width and Height.

1 Like

Wrap your button with SBox widget (SizeBox in UMG) and use WidthOverride and HeightOverride attributes to set exact box size.

nothing helps… my button is always about 200 width 200 height in pixels. its very big and square and i can’t set it’s size, even if change padding. There are no WidthOverride and HeightOverride arguments.

can you please give me full example?

I need something like UE4Editor->Edit->Project Settings…->Description (Buttons Export and Import). Omg that buttons so perfect, they have constant size, and they do not change size when i resize settings window. I love that buttons, but i cannot understand how they work. I use WidgetReflector, i do exactly the same code, and i get nothing similar.

PS: i didnt met so hard and unintuitive GUI functionality in my life.



ChildSlot

    SNew(SBox)
    .WidthOverride(256)
    .HeightOverride(100)
    
        SNew(SButton)
    ]
];


1 Like

I found another problem. GameViewport resizing this button when game window resize. How to fix it? I need always fixed size, even if game window resize.

I set my widget with GEngine->GameViewport->AddViewportWidgetContent.

How to make GEngine->GameViewport not resizing my buttons?

PS: ProjectSettting window does not resize it’s buttons.

You have to disable DPI scaling. You can do that by editing the DPI scale curve in the Project Settings > User Interface > DPI Scale Curve, set all the keys to 1, and it will never scale at any resolution.

I don’t recommend doing it though, games that have a UI that doesn’t scale across different resolutions generally have a terrible experience at anything other than the authored resolution.

Now everything is working!

thnx all.