From 784823ada15e4e81bd24c8a051a792e6b187f958 Mon Sep 17 00:00:00 2001 From: LuoZhihao Date: Tue, 10 Jun 2025 23:03:13 +0800 Subject: [PATCH] Fix `script` property of custom resources inherited from scripts are not saved --- core/io/resource_format_binary.cpp | 4 +++- scene/resources/resource_format_text.cpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 42de02a9e63..7ce92989f7f 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -36,6 +36,7 @@ #include "core/io/missing_resource.h" #include "core/object/script_language.h" #include "core/version.h" +#include "scene/property_utils.h" #include "scene/resources/packed_scene.h" //#define print_bl(m_what) print_line(m_what) @@ -2284,7 +2285,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Refget_class(), F.name); + bool is_script = F.name == CoreStringName(script); + Variant default_value = is_script ? Variant() : PropertyUtils::get_property_default_value(E.ptr(), F.name); if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, p.value, default_value))) { continue; diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 99b906fd06c..1291680bbc7 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1931,7 +1931,8 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const Ref