diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-09-20 15:50:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 15:50:14 +0200 |
commit | 88ebd710f9a8de2d95c0f9cc90d673bf1d9bed6d (patch) | |
tree | a12e90846c0fda6d2fa1b50de05cd7b220f1a4f0 /scene | |
parent | da48a599a4f5b6593346eacb390ece6be84823ca (diff) | |
parent | b0d9f7686c719c2aa38e979e8cc5329b8439b065 (diff) |
Merge pull request #22071 from DualMatrix/preserve_group
Made duplicate_and_reown preserve groups
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/node.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index d4456738ae..06bc12d774 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2116,6 +2116,12 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p node->set(name, value); } + List<GroupInfo> groups; + get_groups(&groups); + + for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) + node->add_to_group(E->get().name, E->get().persistent); + node->set_name(get_name()); p_new_parent->add_child(node); @@ -2210,6 +2216,12 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const { node->set(name, get(name)); } + List<GroupInfo> groups; + get_groups(&groups); + + for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) + node->add_to_group(E->get().name, E->get().persistent); + for (int i = 0; i < get_child_count(); i++) { get_child(i)->_duplicate_and_reown(node, p_reown_map); |