0 votes

Hi everyone. So, basically what I need is to have various UI elements fill in the extra space around an animated sprite as the app scales for different aspect ratios. The sprite in question is like a little TV embedded in the UI playing several layers of an animation inside which must maintain its aspect ratio. These layers are all inside a container and the container is set to fill and expand like all the other UI elements. Problem is the container does not have any built in function it seems to only fill and expand to fit its aspect ratio. This will be a problem if I release the app and the UI is all messed up on phones with different resolutions to what I'm editing with.

Is there such a container that would lock to a certain aspect ratio? Am I just not fully understanding the size flags and how they work? Or do I have to do this with code? And how would I do so, or where would I look in the documentation to figure it out myself?

Thanks!

asked May 10 in Engine by fader (46 points)

I'm not exactly sure what you want to achieve so maybe I'll miss the point completely with my comment here, but then again maybe it may help you:

There is a way to place your UI elements by utilizing anchors: https://docs.godotengine.org/en/3.2/getting_started/step_by_step/ui_introduction_to_the_ui_system.html#place-ui-elements-precisely-with-anchors. In "How to change the anchor" section there, they mention Layout menu which, among other options, has "Full Rect" option.

Now, if you place your UI control as a root node in the scene, you can set the UI control's layout to "Full Rect". This will stretch the control to the size of root viewport, which for the main scene is effectively the size of the game window or display, if game is in fullscreen mode.

If game window size (or display size, if in fullscreen mode) changes, your "Full Rect" root UI control will be resized with it. You now add your other UI controls as children of this "Full Rect" root control (of course, there can be only one root for a scene) and manage their positions and sizes relative to the "Full Rect" control (use various UI containers provided by Godot, use Layout menu on these controls as appropriate, etc)

Yes, I'm already aware of that. Thanks, though. The problem I have is that I cannot seem to control the children individually with such controls. I feel like this was something that could be done even in previous versions of Godot or at least something close to it? I may be wrong about that, it's been a while.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.