Can't change app resolution during runtime (via code)

Godot 4.4.1.stable

Hey everyone :slightly_smiling_face:

I’m really struggling with changing my app resolution during runtime. My project settings are set to 1920x1080, window mode, keep aspect ratio and scale canvas_items.

I’m trying to open a new szene during runtime and set it to 480x720, but nothing works/changes the result at all, it stays at 1920x1080. Appliying the settings during _on_tree_entered() didn’t work either. I found videos on Youtube and even ChatGPT and co. suggest my code should be correct and is the right way to accomplish the resolution change. Could someone please tell me, what I’m doing wrong here? :sweat_smile:

func _ready() → void:
await get_tree().process_frame
DisplayServer.window_set_size(Vector2i(480, 720))
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)

Try to change it to get_window().size = Vector2i(480, 720)

1 Like

This got me in the right direction, thank you very much! :slight_smile:

I managed to change it with this:

	get_window().size = Vector2i(480, 720)
	get_window().content_scale_size = Vector2i(480, 720)
	get_window().mode = Window.MODE_WINDOWED