From a3d8a78f1b7bfe75f12b7d5a511e991e24b8ed79 Mon Sep 17 00:00:00 2001 From: Richard Adenling Date: Tue, 6 Dec 2022 09:56:47 +0100 Subject: [PATCH] Fix for 2D viewport not updating in the editor when the camera moves This fixes a problem with 2D viewports not taking the camera position into consideration when previewed in the editor. Fixes #40441 --- scene/2d/camera_2d.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 4b31bbddaca..229625ad6d1 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -39,8 +39,11 @@ void Camera2D::_update_scroll() { } if (Engine::get_singleton()->is_editor_hint()) { - queue_redraw(); //will just be drawn - return; + queue_redraw(); + // Only set viewport transform when not bound to the main viewport. + if (get_viewport() == get_tree()->get_edited_scene_root()->get_viewport()) { + return; + } } if (!viewport) {