Get the size of the game window in GODOT


The _ready() function is called when a node enters the scene tree, which is a good time to find the size of the game window:

GD script

func _ready():
    screen_size = get_viewport_rect().size 

# Godot 3 
@onready var screen_size: Vector2i = get_viewport().size

 

C#

public override void _Ready()
{
    ScreenSize = GetViewportRect().Size;
}

Form for comments


It will be nice to see comments, reviews or advice

#empty_cookie_group_page

What is 4 + 6?