problems with resizing windows using code
Asked Answered
L

2

0

im trying to create a setting in my game that lets you resize the window to a specific scale, but it is not working. here is my code:

func _process(delta):
      buy_size = $ScrollContainer/VBoxContainer/buy_window_size.value
      $"../Window".content_scale_factor = buy_size
      buy_w = 500 * buy_size
      buy_h = 300 * buy_size
      $"../Window".size = Vector2(buy_w, buy_h)

i tried printing some values and they all returned the right numbers, even doing print($"../Window".size) came out right at the end of the function, but the window itself does not change.

any soulutions? (godot 4.1)

Levant answered 18/9, 2023 at 1:0 Comment(0)
M
0

Try this.

	get_window().size = win_size
	get_window().content_scale_size = win_size
	get_window().content_scale_factor = WIN_SCALE
Minnich answered 18/9, 2023 at 1:5 Comment(0)
L
0

Minnich
i tried:

        buy_size = $ColorRect/VBoxContainer/settings/ColorRect/ScrollContainer/VBoxContainer/buy_window_size.value
	$"../Window".get_window().content_scale_factor = buy_size
	buy_w = 500 * buy_size
	buy_h = 300 * buy_size
	$"../Window".get_window().size = Vector2(buy_w, buy_h)
	$"../Window".get_window().content_scale_size = Vector2(buy_w, buy_h)

i will also note the code i first used worked on a different computer

Levant answered 18/9, 2023 at 20:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.