Godot Version
4.4.stable
Question
Godot 3 used to have a SceneTree with a signal called “screen_resized”. Does anyone know where it went in Godot 4? I want the size of a SubViewport to match the primary screen size set in the project settings.
4.4.stable
Godot 3 used to have a SceneTree with a signal called “screen_resized”. Does anyone know where it went in Godot 4? I want the size of a SubViewport to match the primary screen size set in the project settings.
Hi,
Would it work using get_tree().root.size_changed
?
It is now:
get_viewport().size_changed
Awesome. Thanks!
The signal works. One more question that is related to this.
How can I get the size of my SubViewport to match those in project settings?
@export sub_viewport: SubViewport
func _on_window_size_changed() -> void:
var resolution: Vector2i = get_window().get_size()
sub_viewport.set_size(resolution)
Thanks!
There is a discrepancy between what is printed and what my project window settings are. They don’t match for some reason. Any idea why?
# set the viewport sizes to match the size set in project settings
var resolution: Vector2i = get_window().get_size()
left_viewport.set_size(resolution)
right_viewport.set_size(resolution)
print(resolution)
I figured it out. It was because I was testing the game in the embedded game tab. When I play at full screen it works.
Yeah that embedded game tab has potential, but I’ve turned it off for testing sometimes.
If it’s helpful, I made an addon that handles display stuff, like selecting different monitors, switching between fullscreen and windowed mode, and changing resolution. I pulled your answers from code I had written before in it, so you might find other things that are helpful. It also handles persistence of settings - so if you change something it stores it in a settings file for the user and overwrites those settings when you load the game. Obviously you’ve got more complex things going on in your game. There’s no license on it, but I plan on putting an MIT license on it so do whatever you want with it.
Thanks, I’ll check it out!