From 2ba3561e992fd4b2920518439068ca43ec1e51d9 Mon Sep 17 00:00:00 2001 From: Saracen Date: Tue, 16 Feb 2021 03:52:36 +0000 Subject: [PATCH] Fix to allow TextureArrays to be serialised. --- core/io/resource_format_binary.cpp | 11 +++++++---- core/io/resource_format_binary.h | 2 +- scene/resources/resource_format_text.cpp | 11 +++++++---- scene/resources/resource_format_text.h | 2 +- scene/resources/texture.cpp | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 91691a48d19d..62648f3cee0f 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1674,14 +1674,17 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant Variant value = res->get(E->get().name); if (E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + NonPersistentKey npk; + npk.base = res; + npk.property = E->get().name; + non_persistent_map[npk] = value; + RES sres = value; if (sres.is_valid()) { - NonPersistentKey npk; - npk.base = res; - npk.property = E->get().name; - non_persistent_map[npk] = sres; resource_set.insert(sres); saved_resources.push_back(sres); + } else { + _find_resources(value); } } else { _find_resources(value); diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 06f31cae58ec..a1536dee060b 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -130,7 +130,7 @@ class ResourceFormatSaverBinaryInstance { bool operator<(const NonPersistentKey &p_key) const { return base == p_key.base ? property < p_key.property : base < p_key.base; } }; - Map non_persistent_map; + Map non_persistent_map; Map string_map; Vector strings; diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 709366444c3e..52508cbb45fb 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1416,14 +1416,17 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, Variant v = res->get(I->get().name); if (pi.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + NonPersistentKey npk; + npk.base = res; + npk.property = pi.name; + non_persistent_map[npk] = v; + RES sres = v; if (sres.is_valid()) { - NonPersistentKey npk; - npk.base = res; - npk.property = pi.name; - non_persistent_map[npk] = sres; resource_set.insert(sres); saved_resources.push_back(sres); + } else { + _find_resources(v); } } else { _find_resources(v); diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h index 4f2d8de8137e..129a8c86c743 100644 --- a/scene/resources/resource_format_text.h +++ b/scene/resources/resource_format_text.h @@ -161,7 +161,7 @@ class ResourceFormatSaverTextInstance { bool operator<(const NonPersistentKey &p_key) const { return base == p_key.base ? property < p_key.property : base < p_key.base; } }; - Map non_persistent_map; + Map non_persistent_map; Set resource_set; List saved_resources; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 03e5a676d936..d0e80033c5ea 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -2515,7 +2515,7 @@ void TextureLayered::_bind_methods() { ClassDB::bind_method(D_METHOD("_get_data"), &TextureLayered::_get_data); ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter"), "set_flags", "get_flags"); - ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data"); + ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT), "_set_data", "_get_data"); BIND_ENUM_CONSTANT(FLAG_MIPMAPS); BIND_ENUM_CONSTANT(FLAG_REPEAT);