From 7e9e023e5fb63cc912a165b671bb03591003edc7 Mon Sep 17 00:00:00 2001 From: Tomasz Chabora Date: Tue, 14 May 2019 02:11:06 +0200 Subject: [PATCH] Keep editable children on node duplicate --- editor/scene_tree_dock.cpp | 44 +++++++++++++++++++++----------------- editor/scene_tree_dock.h | 3 ++- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a41f10607b8..ced9d3a0404 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -517,6 +517,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(editor_selection, "clear"); Node *dupsingle = NULL; + List editable_children; for (List::Element *E = selection.front(); E; E = E->next()) { @@ -529,6 +530,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Map duplimap; Node *dup = node->duplicate_from_editor(duplimap); + if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node)) + editable_children.push_back(dup); + ERR_CONTINUE(!dup); if (selection.size() == 1) @@ -561,6 +565,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (dupsingle) editor->push_item(dupsingle); + for (List::Element *E = editable_children.front(); E; E = E->next()) + _toggle_editable_children(E->get()); + } break; case TOOL_REPARENT: { @@ -796,7 +803,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editable_instance_remove_dialog->popup_centered_minsize(); break; } - _toggle_editable_children(); + _toggle_editable_children(node); } } } break; @@ -1610,30 +1617,27 @@ void SceneTreeDock::_script_created(Ref