Merge pull request #71822 from adamscott/fix-resource-duplicate
Fix `Resource::duplicate()` missing packed arrays
This commit is contained in:
commit
10b47d03c8
1 changed files with 28 additions and 8 deletions
|
@ -260,15 +260,35 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
|
||||||
}
|
}
|
||||||
Variant p = get(E.name);
|
Variant p = get(E.name);
|
||||||
|
|
||||||
if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) {
|
switch (p.get_type()) {
|
||||||
r->set(E.name, p.duplicate(p_subresources));
|
case Variant::Type::DICTIONARY:
|
||||||
} else if (p.get_type() == Variant::OBJECT && !(E.usage & PROPERTY_USAGE_NEVER_DUPLICATE) && (p_subresources || (E.usage & PROPERTY_USAGE_ALWAYS_DUPLICATE))) {
|
case Variant::Type::ARRAY:
|
||||||
Ref<Resource> sr = p;
|
case Variant::Type::PACKED_BYTE_ARRAY:
|
||||||
if (sr.is_valid()) {
|
case Variant::Type::PACKED_COLOR_ARRAY:
|
||||||
r->set(E.name, sr->duplicate(p_subresources));
|
case Variant::Type::PACKED_INT32_ARRAY:
|
||||||
|
case Variant::Type::PACKED_INT64_ARRAY:
|
||||||
|
case Variant::Type::PACKED_FLOAT32_ARRAY:
|
||||||
|
case Variant::Type::PACKED_FLOAT64_ARRAY:
|
||||||
|
case Variant::Type::PACKED_STRING_ARRAY:
|
||||||
|
case Variant::Type::PACKED_VECTOR2_ARRAY:
|
||||||
|
case Variant::Type::PACKED_VECTOR3_ARRAY: {
|
||||||
|
r->set(E.name, p.duplicate(p_subresources));
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case Variant::Type::OBJECT: {
|
||||||
|
if (!(E.usage & PROPERTY_USAGE_NEVER_DUPLICATE) && (p_subresources || (E.usage & PROPERTY_USAGE_ALWAYS_DUPLICATE))) {
|
||||||
|
Ref<Resource> sr = p;
|
||||||
|
if (sr.is_valid()) {
|
||||||
|
r->set(E.name, sr->duplicate(p_subresources));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
r->set(E.name, p);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default: {
|
||||||
|
r->set(E.name, p);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
r->set(E.name, p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue