Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size_changed signal doesn't work on root viewport when using custom scenetree #64054

Closed
blipk opened this issue Aug 7, 2022 · 1 comment
Closed

Comments

@blipk
Copy link

blipk commented Aug 7, 2022

Godot version

3.4.4.stable.arch_linux

System information

Arch

Issue description

Connecting to the size_changed signal on get_tree().get_root() does not work if using a custom SceneTree loaded via the -s command line argument

Steps to reproduce

  • Set a custom SceneTree via command line args (Project Settings -> Editor -> Main Run Args) e.g. -s SceneTreeCustom.gd
  • Try to connect to size_changed signal on viewport
extends SceneTree
class_name SceneTreeCustom
func _initialize():
	_on_viewport_resized()
	root.connect("size_changed", self, "_on_viewport_resized")
func _on_viewport_resized():
	prints("Resizing:", root.size)

or via another script

func _ready():
	_on_viewport_resized()
	get_tree().root.connect("size_changed", self, "_on_viewport_resized")
func _on_viewport_resized():
	prints("Resizing:", get_tree().root.size)
  • Nothing is printed when resizing the window
  • It will work if connecting to the signal without the custom scene tree cmdline arg
  • I also tried get_tree().get_root() and get_viewport() and it did not work

Minimal reproduction project

No response

@blipk
Copy link
Author

blipk commented Aug 9, 2022

Screen size is not always the same as viewport but this works for what I needed to do:

extends SceneTree
class_name SceneTreeCustom
func _initialize():
	self.connect("screen_resized", self, "_on_screen_resized")
func _on_screen_resized():
	prints("Resizing window:", get_root().size, OS.get_window_size())

@blipk blipk closed this as completed Jun 12, 2023
@akien-mga akien-mga added archived and removed bug labels Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants