summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/scene_tree_dock.cpp9
-rwxr-xr-xscene/main/node.cpp21
-rw-r--r--scene/resources/material.cpp8
3 files changed, 31 insertions, 7 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index afdf48b314..4fe24a2eff 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -823,7 +823,14 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set(name, p_node->get(name));
+ Variant value = p_node->get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+ node->set(name, value);
}
List<Node::GroupInfo> group_info;
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index c3d9d97c5a..a543dba9cb 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2117,7 +2117,15 @@ Node *Node::_duplicate(int p_flags) const {
if (!(p_flags & DUPLICATE_SCRIPTS) && name == "script/script")
continue;
- node->set(name, get(name));
+ Variant value = get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+
+ node->set(name, value);
}
node->set_name(get_name());
@@ -2199,7 +2207,16 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set(name, get(name));
+
+ Variant value = get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+
+ node->set(name, value);
}
node->set_name(get_name());
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index a187692bcb..abe9a00c3f 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -67,8 +67,8 @@ RID Material::get_rid() const {
}
void Material::_validate_property(PropertyInfo &property) const {
- if (!_can_do_next_pass() && property.name=="next_pass") {
- property.usage=0;
+ if (!_can_do_next_pass() && property.name == "next_pass") {
+ property.usage = 0;
}
}
@@ -80,7 +80,7 @@ void Material::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_render_priority", "priority"), &Material::set_render_priority);
ClassDB::bind_method(D_METHOD("get_render_priority"), &Material::get_render_priority);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "render_priority", PROPERTY_HINT_RANGE, itos(RENDER_PRIORITY_MIN) + "," + itos(RENDER_PRIORITY_MAX) + ",1"), "set_render_priority", "get_render_priority");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "render_priority", PROPERTY_HINT_RANGE, itos(RENDER_PRIORITY_MIN) + "," + itos(RENDER_PRIORITY_MAX) + ",1"), "set_render_priority", "get_render_priority");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_pass", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_next_pass", "get_next_pass");
BIND_CONSTANT(RENDER_PRIORITY_MAX);
@@ -212,7 +212,7 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id
bool ShaderMaterial::_can_do_next_pass() const {
- return shader.is_valid() && shader->get_mode()==Shader::MODE_SPATIAL;
+ return shader.is_valid() && shader->get_mode() == Shader::MODE_SPATIAL;
}
ShaderMaterial::ShaderMaterial() {