mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Merge pull request #86600 from nikitalita/fix-missing-resources
Fix `MissingResource` properties being stripped on save
This commit is contained in:
@@ -600,7 +600,7 @@ Error ResourceLoaderText::load() {
|
||||
if (do_assign) {
|
||||
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.
|
||||
@@ -723,24 +723,25 @@ Error ResourceLoaderText::load() {
|
||||
if (error) {
|
||||
if (error != ERR_FILE_EOF) {
|
||||
_printerr();
|
||||
} else {
|
||||
error = OK;
|
||||
if (cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) {
|
||||
if (!ResourceCache::has(res_path)) {
|
||||
resource->set_path(res_path);
|
||||
}
|
||||
resource->set_as_translation_remapped(translation_remapped);
|
||||
} else {
|
||||
resource->set_path_cache(res_path);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
return error;
|
||||
// EOF, Done parsing.
|
||||
error = OK;
|
||||
if (cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) {
|
||||
if (!ResourceCache::has(res_path)) {
|
||||
resource->set_path(res_path);
|
||||
}
|
||||
resource->set_as_translation_remapped(translation_remapped);
|
||||
} else {
|
||||
resource->set_path_cache(res_path);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!assign.is_empty()) {
|
||||
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.
|
||||
@@ -1900,7 +1901,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const Ref<Reso
|
||||
#endif
|
||||
}
|
||||
|
||||
Dictionary missing_resource_properties = p_resource->get_meta(META_MISSING_RESOURCES, Dictionary());
|
||||
Dictionary missing_resource_properties = res->get_meta(META_MISSING_RESOURCES, Dictionary());
|
||||
|
||||
List<PropertyInfo> property_list;
|
||||
res->get_property_list(&property_list);
|
||||
@@ -1912,7 +1913,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const Ref<Reso
|
||||
continue;
|
||||
}
|
||||
|
||||
if (PE->get().usage & PROPERTY_USAGE_STORAGE) {
|
||||
if (PE->get().usage & PROPERTY_USAGE_STORAGE || missing_resource_properties.has(PE->get().name)) {
|
||||
String name = PE->get().name;
|
||||
Variant value;
|
||||
if (PE->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
|
||||
|
||||
Reference in New Issue
Block a user