From b51d9117ed7ad6766e514486451da0e2d1c6afd5 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 8 Jul 2024 23:52:16 +0200 Subject: [PATCH] Fix wrong inspected node after drag&drop --- editor/scene_tree_dock.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 94bd3e16d30..25de9facb24 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2276,6 +2276,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V Vector former_names; int inc = 0; + bool need_edit = false; for (int ni = 0; ni < p_nodes.size(); ni++) { // No undo implemented for this yet. @@ -2296,7 +2297,11 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V inc--; // If the child will generate a gap when moved, adjust. } - if (!same_parent) { + if (same_parent) { + // When node is reparented to the same parent, EditorSelection does not change. + // After hovering another node, the inspector has to be manually updated in this case. + need_edit = select_node_hovered_at_end_of_drag; + } else { undo_redo->add_do_method(node->get_parent(), "remove_child", node); undo_redo->add_do_method(new_parent, "add_child", node, true); } @@ -2401,6 +2406,10 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V perform_node_renames(nullptr, &path_renames); undo_redo->commit_action(); + + if (need_edit) { + EditorNode::get_singleton()->edit_current(); + } } void SceneTreeDock::_script_created(Ref