How to set size and position of a custom widget as a child of an another custom widget?

Hello!

I have a problem with UE 4 widget postition and size logic. I have created two widgets: MainMenu_Options and MainMenu_OptionsGame. MainMenu_OptionsGame must be a child of MainMenu_Options.

Screen 1. MainMenu_OptionsGame.

Screen 2. How I want MainMenu_OptionsGame to be on MainMenu_Options.

Screen 3. How MainMenu_OptionsGame is actually looks like on MainMenu_Options, when I add it with AddChild.

What shall I do?

P.S. If there are any of tutorials about how actually UE 4 widget sustem works, I shall be grateful for them. Why to use 100+ widget classes with incomprehensible pos and size settings? Why not just to set size and pos relative to parent with a script? Is it possible?

Why not just to set size and pos
relative to parent with a script? Is
it possible?

Any elements that are direct children of the Canvas Panel can do this:

For any non-canvas panels, there is Padding - which tells the parent how much border space to reserve, this will squish the child. :expressionless:

2 Likes

Judging by the hierarchy, the MainMenu_OptionsGame does not need a canvas. You can right click it and replace with child and ensure that all VBs are set to horizontal and vertical Fill.

You’ve anchored your menu to full stretch, so you’re working with offsets now. Otherwise you’ll be able to do this:

310814-annotation-2020-08-20-111514.jpg

Thanks, now I shall know it.

If I shall replace CanvasPanel with Vertical Box, it still looks wrong, when added as child.

Can you show the hierarchy of main widget, where the menu is misaligned?