Reorder C# script properties to fix editor serialization

This commit is contained in:
alpacat 2024-09-15 03:54:40 +08:00
parent 6681f2563b
commit 7df5b78aca
1 changed files with 34 additions and 7 deletions

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();
for (PropertyInfo &prop : props) {
validate_property(prop);
p_properties->push_front(prop);
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_back(prop);
}
top = top->base_script.ptr();
}
}