From 636b1e4518bbe50f29a90e2da633c352254e20be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 22 Jun 2020 14:16:59 +0200 Subject: [PATCH] CanvasItemEditor: Fix losing position for drag'n'dropped scenes Fixes #26549. Supersedes #36309. (cherry picked from commit a403131a25e165471f96ee2eb3f3db91994f8ce1) --- editor/plugins/canvas_item_editor_plugin.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 48e1d080298..bebf46f3127 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -6013,6 +6013,11 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons Vector2 target_pos = canvas_item_editor->get_canvas_transform().affine_inverse().xform(p_point); target_pos = canvas_item_editor->snap_point(target_pos); target_pos = parent_ci->get_global_transform_with_canvas().affine_inverse().xform(target_pos); + // Preserve instance position of the original scene. + CanvasItem *instance_ci = Object::cast_to(instanced_scene); + if (instance_ci) { + target_pos += instance_ci->_edit_get_position(); + } editor_data->get_undo_redo().add_do_method(instanced_scene, "set_position", target_pos); }