Merge pull request #97014 from hayahane/fix_script_property_order

Reorder C# script properties to fix editor serialization
This commit is contained in:
Rémi Verschelde 2024-09-19 17:13:34 +02:00
commit ae872a4ed5
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -1497,12 +1497,24 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {
List<PropertyInfo> props;
script->get_script_property_list(&props);
ERR_FAIL_COND(!script.is_valid());
#ifdef TOOLS_ENABLED
for (const PropertyInfo &prop : script->exported_members_cache) {
props.push_back(prop);
}
#else
for (const KeyValue<StringName, PropertyInfo> &E : script->member_info) {
props.push_front(E.value);
}
#endif
for (PropertyInfo &prop : props) {
validate_property(prop);
p_properties->push_back(prop);
}
// Call _get_property_list
ERR_FAIL_COND(!script.is_valid());
StringName method = SNAME("_get_property_list");
Variant ret;
@ -1524,10 +1536,25 @@ void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {
}
}
props.reverse();
CSharpScript *top = script.ptr()->base_script.ptr();
while (top != nullptr) {
props.clear();
#ifdef TOOLS_ENABLED
for (const PropertyInfo &prop : top->exported_members_cache) {
props.push_back(prop);
}
#else
for (const KeyValue<StringName, PropertyInfo> &E : top->member_info) {
props.push_front(E.value);
}
#endif
for (PropertyInfo &prop : props) {
validate_property(prop);
p_properties->push_front(prop);
p_properties->push_back(prop);
}
top = top->base_script.ptr();
}
}