How do I make resolution options for my game with stretch mode as canvas_items

Godot Version

4.4.stable.mono

Question

I’m making a game where I want to be able to have a properly resizable window, which I have been able to do with stretch mode set to canvas_items, but I also want a way for the player to set resolution, for example to 720p or 1080p, with an OptionButton. Is there any way to do this? I’ve tried adding a subviewport and subviewportcontainer and setting the stretch shrink of the container but that didn’t work. I’ve also tried using the subviewport’s size 2d override and changing the scale of my main scene, but that didn’t work either.

Any help is appreciated!

1 Like

Hi, this video explains on how to choose your resolution:

i already tried that tutorial :wilted_flower:

1 Like

I believe you want:

func scale_zoom(zoom: float) -> void:
	get_viewport().set_scaling_3d_scale(zoom)

or

func scale_zoom(zoom: float) -> void:
	get_viewport().set_scaling_2d_scale(zoom)

I used it in this plugin here: GitHub - dragonforge-dev/dragonforge-controller: A Controller autoload singleton to handle game input from gamepads (controllers) and keyboard/mouse.

I am working on a UI example to go with it, but I’m not done yet.

1 Like

this works, thanks!

1 Like