Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resources being skipped in InstancePlaceholder #94345

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions scene/main/instance_placeholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,28 @@ 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> 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;
}

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
Expand Down Expand Up @@ -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;
}
}
}

Expand Down
Loading