From 3cfbabfa59d3501b67acea28cb02afcdbfa18e2e Mon Sep 17 00:00:00 2001 From: Richard Adenling Date: Tue, 6 Dec 2022 08:34:40 +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 9dea44d72f6..62148ea5543 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -41,8 +41,11 @@ void Camera2D::_update_scroll() { } if (Engine::get_singleton()->is_editor_hint()) { - update(); //will just be drawn - return; + update(); + // 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) {