Godot Version
Godot 4.6
Question
I’m making a game in Godot where the size of the window changes when controlled in the settings. The issue is that the size and positioning of the containers does not change until the window is moved manually. How do I refresh the window to cause this change in code?
extends HBoxContainer
const hoveredScale = 0.45;
const unhoveredScale = 0.4;
const hoverChangeTime = 0.08;
var windowSizePresets = [Vector2i(3840, 2160), Vector2i(2560, 1440), Vector2i(1920, 1080), Vector2i(1280, 720), Vector2i(854, 480)];
func _on_settings_mouse_entered() -> void:
var hoveredTween = get_tree().create_tween().set_trans(Tween.TRANS_BOUNCE);
hoveredTween.tween_property(self, "scale", Vector2.ONE*hoveredScale, hoverChangeTime);
func _on_settings_mouse_exited() -> void:
var unhoveredTween = get_tree().create_tween().set_trans(Tween.TRANS_BOUNCE);
unhoveredTween.tween_property(self, "scale", Vector2.ONE*unhoveredScale, hoverChangeTime);
func _on_settings_button_button_up() -> void:
%"Settings Background".visible = !%"Settings Background".visible;
func _on_window_size_button_item_selected(index: int) -> void:
DisplayServer.window_set_size(windowSizePresets[index]);
