You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Fix missing resource properties being dropped on save
This commit is contained in:
@@ -833,7 +833,7 @@ Error ResourceLoaderBinary::load() {
|
||||
}
|
||||
|
||||
bool set_valid = true;
|
||||
if (value.get_type() == Variant::OBJECT && missing_resource != nullptr) {
|
||||
if (value.get_type() == Variant::OBJECT && missing_resource == nullptr && ResourceLoader::is_creating_missing_resources_if_class_unavailable_enabled()) {
|
||||
// If the property being set is a missing resource (and the parent is not),
|
||||
// then setting it will most likely not work.
|
||||
// Instead, save it as metadata.
|
||||
@@ -2220,10 +2220,10 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Ref<Re
|
||||
|
||||
List<ResourceData> resources;
|
||||
|
||||
Dictionary missing_resource_properties = p_resource->get_meta(META_MISSING_RESOURCES, Dictionary());
|
||||
|
||||
{
|
||||
for (const Ref<Resource> &E : saved_resources) {
|
||||
Dictionary missing_resource_properties = E->get_meta(META_MISSING_RESOURCES, Dictionary());
|
||||
|
||||
ResourceData &rd = resources.push_back(ResourceData())->get();
|
||||
rd.type = _resource_get_class(E);
|
||||
|
||||
@@ -2238,7 +2238,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Ref<Re
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((F.usage & PROPERTY_USAGE_STORAGE)) {
|
||||
if ((F.usage & PROPERTY_USAGE_STORAGE) || missing_resource_properties.has(F.name)) {
|
||||
Property p;
|
||||
p.name_idx = get_string_index(F.name);
|
||||
|
||||
@@ -2253,7 +2253,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Ref<Re
|
||||
p.value = E->get(F.name);
|
||||
}
|
||||
|
||||
if (p.pi.type == Variant::OBJECT && missing_resource_properties.has(F.name)) {
|
||||
if (F.type == Variant::OBJECT && missing_resource_properties.has(F.name)) {
|
||||
// Was this missing resource overridden? If so do not save the old value.
|
||||
Ref<Resource> res = p.value;
|
||||
if (res.is_null()) {
|
||||
|
||||
Reference in New Issue
Block a user