summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-09-21 10:53:58 +0200
committerGitHub <noreply@github.com>2017-09-21 10:53:58 +0200
commita1779c90448e2d86b81812c45814983d142ae9b4 (patch)
tree17949283152bbee6e14ea98f8e53adb4802a12d7
parent82f13288dddcb6add01ddec5cb62a31d85f92bfd (diff)
parent521280ec444d5bc58c8f7bcb044368d20f10f48a (diff)
Merge pull request #11013 from MednauN/master
Fix duplication of node with script
-rwxr-xr-xscene/main/node.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 0ab41b40d8..658701dcc7 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "node.h"
+#include "core/core_string_names.h"
#include "instance_placeholder.h"
#include "io/resource_loader.h"
#include "message_queue.h"
@@ -2104,12 +2105,22 @@ Node *Node::_duplicate(int p_flags) const {
get_property_list(&plist);
+ StringName script_property_name = CoreStringNames::get_singleton()->_script;
+
+ if (p_flags & DUPLICATE_SCRIPTS) {
+ bool is_valid = false;
+ Variant script = get(script_property_name, &is_valid);
+ if (is_valid) {
+ node->set(script_property_name, script);
+ }
+ }
+
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- if (!(p_flags & DUPLICATE_SCRIPTS) && name == "script/script")
+ if (name == script_property_name)
continue;
Variant value = get(name);