How can I make control node margins adjust to the window resolution?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Cogan

When the window resolution changes, I would like the margins to stay the same. Right now, if i adjust the window size, a part of the control node is cut off. I would like for the control node to readjust its size based on the margins. Changing how the screen expands will not work in this situation. All of my attempts so far have been unsuccessful.

:bust_in_silhouette: Reply From: Yuminous

You need to make use of the anchor points — these four green pins:

Anchor Points
UI elements all move relative to their location.
If they are all together like this then your element will just translate:

Default — Top-RightCentered
Instead, dragging them around the corners of your UI element like this will anchor the element to its original position and resize it relative to the screen like you are wanting:

Anchor Points surrounding the UI element
Anchored to the Original Position

You can read a little bit more about UI anchoring here:

Hope that it helps! Good luck!

Okay, I was able to do it through a process inspired by this post. basically, I put the anchor in the top right and then I just wrote some code:

margin_right = get_setting(“display/window/size/width”) - desired_margin
margin_bottom = get_setting(“display/window/size/height”) - desired_margin

desired margin is a variable with your desired margin. If it is changed all margins have to be set. I’m just putting this here in the hopes that somebody else finds it and also so that people know that I figured it out.

Cogan | 2021-07-30 23:40

:bust_in_silhouette: Reply From: Snail0259

In addition to what yuminous said, you can also go into settings, and under display -> window, change mode to 2d or viewport, and change aspect to expand.

This does work, but it doesn’t do quite what I need it to.

Cogan | 2021-07-15 20:51

What isn’t working for you? Beyond these solutions, it’s possible to change almost anything about control node sizing and the display of content (like text) through scripting.

Yuminous | 2021-07-17 02:37