How to get the real size of a Control node on screen?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Mivik

Is there any way I can get the real size of a Control node on screen?

My stretch mode is 2d/expand. I’ve tried Node.get_global_rect().size and Control.size, but both of their results didn’t change although I resized the window. The results are relative to the window size set in project configuration instead of their real size on screen.

I need the real size of a node on screen since my shaders depend on the screen resolution.

:bust_in_silhouette: Reply From: Mivik

Solved with the help of @nitricswight. One can just compare the current window size with the size in ProjectSettings to obtain the strech scale.

var screen_size = get_tree().get_root().size
var set_width = ProjectSettings.get("display/window/size/width")
var set_height = ProjectSettings.get("display/window/size/height")
var real_size = size * screen_size / Vector2(set_width, set_height)