How to change window size using GDscript

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

I am trying to make a dropdown menu which changes the resolution of the window
Godot 4.0 stable release change alot about the engine and the command OS.set_window_size() does not work no more

I looked everywhere for information about how to achieve this with the new version of godot but i couldn’t find anything

:bust_in_silhouette: Reply From: LazyBigCat

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

1 Like
:bust_in_silhouette: Reply From: BrnLng

don’t know about making it run by a menu, but the code I use to fix it is this:

extends EditorScript

func _run():
	if Engine.is_editor_hint:
		var screen_size = DisplayServer.screen_get_size()
		var window = get_editor_interface().get_window()
		window.mode = Window.MODE_WINDOWED
		window.position = Vector2i(-8, 0)
		window.size = Vector2i(screen_size.x - 66, screen_size.y - 1)
# these precise magic numbers are just how I like, tweak as needed