![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | RitzyMage |
Using the helpful tutorial at https://docs.godotengine.org/en/stable/tutorials/viewports/multiple_resolutions.html, I successfully made my game render at 1080p no matter the window size. (It has stretch_mode
= 2d
and strecth_aspect
= keep
). I can change the values in the project settings dialog and indeed the aspect ratio changes.
However, I’d like to allow the user to pick an aspect ratio at runtime. I tried changing the root viewport size (which didn’t work the way I expected), but then realized that there was a way to change the project settings dynmically.
I can call the ProjectSettings
class ( ProjectSettings — Godot Engine (stable) documentation in English ) and use set_setting on the base size ("display/window/size/width"
and "display/window/size/height"
), but the rendering does not change. Calls to get_setting
show that in fact, the setting is set.
Is there something I am missing or is this an engine bug? If I’m missing something, how do I properly change the aspect ratio at runtime.