0 votes

Hi. I'm very new to Godot Engine, so sorry for this newbie question.

In my project, i have some interactive elements wich i need to always preserve its size, no matter the windows size. To achieve this, i disabled the Stretch mode in the project settings.

The problem is I also need the background image to stretch or shrink according to windows size. I'm using a TextureRect node for the background image. Due to my limited knowledge in godot, the only solution i have found is to adjust the TextureRect's scale_rect property by code.

At first, i thoght i could simply adjust the background size automatically by making the TextureRec a child of some type of container (PanelContainer, HboxContainer, etc) and then tinker with their size flags, to get an 'automatic' background reescaling, but with this approach, the TextureRect doesn't change its size when i change the size of the container.

Is there any method to reescale the TextureRect to window size other than doing it directly by code?

Thank you and sorry for my bad english. :)

Godot version 3.4.2
in Engine by (12 points)

1 Answer

+1 vote

Project Settings -> Display -> Window -> Stretch -> Mode = 2D.
Then all images will automatically scale follow the window size. If you want scale whole screen images, I think this is the simplest way.

But if you only want one specific image automatically scale when the window size changeed, use code to control will be better.

By the way, when you use code, you also can scale all the screen images by controlling the camera.

by (526 points)

I'll keep your tip about the camera in mind. 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.