This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

On my android project, I set the project resolution to my phone resolution. My GUI elements are well anchored and are sized accordingly.
But when I share the app to a phone with lower resolution, the buttons and other GUI elements are anchored, but do not resize accordingly.
How do I resize them with the viewport?

in Engine by (64 points)

1 Answer

+2 votes

I'm guessing you have anchored them correctly but for the size you should be using the viewport_size as a multiplier instead of hardcoding it.

let's say you development viewport size 100x200. In this size,your control has a size of 20x20. You don't put 20x20 in your control size, but rather you set it via code during _ready().

rect_size.x = get_viewport().size.x / 5

rect_size.y = get_viewport().size.y / 10

Now when you resize your viewport to 200x400, your control will automatically resize to 40x40 but stay anchored at the right place.

by (115 points)

Wow! It works beautifully.
Thank you very much

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.