Camera2D: Fix crash calling align when not in tree

Fixes #45976.
This commit is contained in:
Rémi Verschelde 2021-02-14 11:40:25 +01:00
parent db8c2410a4
commit 5a22bd2b3e
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -94,7 +94,7 @@ Vector2 Camera2D::get_zoom() const {
Transform2D Camera2D::get_camera_transform() {
if (!get_tree())
if (!get_tree() || !viewport)
return Transform2D();
ERR_FAIL_COND_V(custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Transform2D());
@ -498,6 +498,7 @@ void Camera2D::reset_smoothing() {
void Camera2D::align() {
ERR_FAIL_COND(!is_inside_tree() || !viewport);
ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));
Size2 screen_size = viewport->get_visible_rect().size;