How can I change the main viewport size dynamically?

Godot Version

4.3

Question

I am trying to solve my previous issue by dynamically changing the main viewport size when loading the project, but I couldn’t figure out how to do it. I’ve tried the following:

  • Changing the project settings in a _ready function: Does nothing
  • Changing the project settings in a _process function: Does nothing
  • Setting get_viewport().size in a _ready function: Does nothing
  • Setting get_viewport().size in a _process function: Changes the size of the viewport, but without expanding it

What am I doing wrong?

Try get_window().size = Vector2i(width, height)

I’ve put that in a _ready and it did nothing on mobile

Someone on the lemmy community helped me figure out the solution:

get_window().content_scale_size = DisplayServer.window_get_size() / 3