Skip to content

Commit ae872a4

Browse files
committed
Merge pull request #97014 from hayahane/fix_script_property_order
Reorder C# script properties to fix editor serialization
2 parents 575c321 + 7df5b78 commit ae872a4

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

modules/mono/csharp_script.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,11 +1497,23 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
14971497

14981498
void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {
14991499
List<PropertyInfo> props;
1500-
script->get_script_property_list(&props);
1500+
ERR_FAIL_COND(!script.is_valid());
1501+
#ifdef TOOLS_ENABLED
1502+
for (const PropertyInfo &prop : script->exported_members_cache) {
1503+
props.push_back(prop);
1504+
}
1505+
#else
1506+
for (const KeyValue<StringName, PropertyInfo> &E : script->member_info) {
1507+
props.push_front(E.value);
1508+
}
1509+
#endif
15011510

1502-
// Call _get_property_list
1511+
for (PropertyInfo &prop : props) {
1512+
validate_property(prop);
1513+
p_properties->push_back(prop);
1514+
}
15031515

1504-
ERR_FAIL_COND(!script.is_valid());
1516+
// Call _get_property_list
15051517

15061518
StringName method = SNAME("_get_property_list");
15071519

@@ -1524,10 +1536,25 @@ void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {
15241536
}
15251537
}
15261538

1527-
props.reverse();
1528-
for (PropertyInfo &prop : props) {
1529-
validate_property(prop);
1530-
p_properties->push_front(prop);
1539+
CSharpScript *top = script.ptr()->base_script.ptr();
1540+
while (top != nullptr) {
1541+
props.clear();
1542+
#ifdef TOOLS_ENABLED
1543+
for (const PropertyInfo &prop : top->exported_members_cache) {
1544+
props.push_back(prop);
1545+
}
1546+
#else
1547+
for (const KeyValue<StringName, PropertyInfo> &E : top->member_info) {
1548+
props.push_front(E.value);
1549+
}
1550+
#endif
1551+
1552+
for (PropertyInfo &prop : props) {
1553+
validate_property(prop);
1554+
p_properties->push_back(prop);
1555+
}
1556+
1557+
top = top->base_script.ptr();
15311558
}
15321559
}
15331560

0 commit comments

Comments
 (0)