From 260c05152da353efd78fd1521be4c4c3f9ea8f99 Mon Sep 17 00:00:00 2001 From: matheusmdx Date: Sun, 14 Jul 2024 08:33:14 -0300 Subject: [PATCH] Fix resources being skipped in InstancePlaceholder --- scene/main/instance_placeholder.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index f36bbe93954..29166f3d920 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -161,12 +161,12 @@ void InstancePlaceholder::set_value_on_instance(InstancePlaceholder *p_placehold } switch (current_type) { - case Variant::Type::NIL: - if (placeholder_type != Variant::Type::NODE_PATH) { + case Variant::Type::NIL: { + Ref resource = p_set.value; + if (placeholder_type != Variant::Type::NODE_PATH && !resource.is_valid()) { break; } - // If it's nil but we have a NodePath, we guess what works. - + // If it's nil but we have a NodePath or a Resource, we guess what works. p_instance->set(p_set.name, p_set.value, &is_valid); if (is_valid) { break; @@ -174,13 +174,15 @@ void InstancePlaceholder::set_value_on_instance(InstancePlaceholder *p_placehold p_instance->set(p_set.name, try_get_node(p_placeholder, p_instance, p_set.value), &is_valid); break; - case Variant::Type::OBJECT: + } + case Variant::Type::OBJECT: { if (placeholder_type != Variant::Type::NODE_PATH) { break; } // Easiest case, we want a node, but we have a deferred NodePath. p_instance->set(p_set.name, try_get_node(p_placeholder, p_instance, p_set.value)); break; + } case Variant::Type::ARRAY: { // If we have reached here it means our array types don't match, // so we will convert the placeholder array into the correct type @@ -209,9 +211,10 @@ void InstancePlaceholder::set_value_on_instance(InstancePlaceholder *p_placehold } break; } - default: + default: { WARN_PRINT(vformat("Property '%s' with type '%s' could not be set when creating instance of '%s'.", p_set.name, Variant::get_type_name(current_type), p_placeholder->get_name())); break; + } } }