Merge pull request #83597 from SaracenOne/duplicate_foreign_nodes
Support duplication of foreign nodes.
This commit is contained in:
commit
cd46addfca
@ -681,10 +681,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_validate_no_foreign()) {
|
||||
break;
|
||||
}
|
||||
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
if (selection.size() == 0) {
|
||||
break;
|
||||
@ -704,7 +700,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||
Node *parent = node->get_parent();
|
||||
|
||||
List<Node *> owned;
|
||||
node->get_owned_by(node->get_owner(), &owned);
|
||||
Node *owner = node;
|
||||
while (owner) {
|
||||
List<Node *> cur_owned;
|
||||
node->get_owned_by(owner, &cur_owned);
|
||||
owner = owner->get_owner();
|
||||
for (Node *F : cur_owned) {
|
||||
owned.push_back(F);
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<const Node *, Node *> duplimap;
|
||||
Node *dup = node->duplicate_from_editor(duplimap);
|
||||
@ -724,9 +728,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||
continue;
|
||||
}
|
||||
Node *d = duplimap[F];
|
||||
undo_redo->add_do_method(d, "set_owner", node->get_owner());
|
||||
undo_redo->add_do_method(d, "set_owner", edited_scene);
|
||||
}
|
||||
undo_redo->add_do_method(editor_selection, "add_node", dup);
|
||||
undo_redo->add_do_method(dup, "set_owner", edited_scene);
|
||||
undo_redo->add_undo_method(parent, "remove_child", dup);
|
||||
undo_redo->add_do_reference(dup);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user