How to change the root viewport's size?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Yeldham

My first attempt was changing it directly:

get_tree().get_root().size

But it only affected Control nodes, and when the window had it size changed, even they reverted back to normal.

:bust_in_silhouette: Reply From: DodoIta

You could do it in the project settings, under Display->Window set the Width and Height values to whatever you need.

I need to do it while in-game.

Yeldham | 2018-06-26 16:15

You could do a little trick and use a Camera2D node and then zoom in an out whenever you need it.

DodoIta | 2018-06-29 09:39

Is there really no way of changing the root’s size?

Yeldham | 2018-06-29 16:43

:bust_in_silhouette: Reply From: happycamper

OS.window__size=Vector2(width ,height)

No, not window size, the viewport’s size.

Yeldham | 2018-06-27 02:44

In Godot 4.x, use:
get_window().content_scale_size = Vector2i(new_width, new_height)