Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C# tool script displaying exported variables in the wrong order #48143

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1614,8 +1614,8 @@ void CSharpInstance::get_properties_state_for_reloading(List<Pair<StringName, Va

void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {

for (Map<StringName, PropertyInfo>::Element *E = script->member_info.front(); E; E = E->next()) {
p_properties->push_back(E->value());
for (const List<StringName>::Element *E = script->member_order.front(); E; E = E->next()) {
p_properties->push_back(script->member_info[E->get()]);
}

// Call _get_property_list
Expand Down Expand Up @@ -2234,6 +2234,7 @@ void CSharpScript::_update_member_info_no_exports() {
exports_invalidated = false;

member_info.clear();
member_order.clear();

GDMonoClass *top = script_class;

Expand All @@ -2250,6 +2251,7 @@ void CSharpScript::_update_member_info_no_exports() {
StringName member_name = field->get_name();

member_info[member_name] = prop_info;
member_order.push_front(member_name);
exported_members_cache.push_front(prop_info);
exported_members_defval_cache[member_name] = Variant();
}
Expand All @@ -2264,6 +2266,7 @@ void CSharpScript::_update_member_info_no_exports() {
StringName member_name = property->get_name();

member_info[member_name] = prop_info;
member_order.push_front(member_name);
exported_members_cache.push_front(prop_info);
exported_members_defval_cache[member_name] = Variant();
}
Expand Down Expand Up @@ -2297,6 +2300,7 @@ bool CSharpScript::_update_exports() {
changed = true;

member_info.clear();
member_order.clear();

#ifdef TOOLS_ENABLED
MonoObject *tmp_object = nullptr;
Expand Down Expand Up @@ -2357,6 +2361,7 @@ bool CSharpScript::_update_exports() {
StringName member_name = field->get_name();

member_info[member_name] = prop_info;
member_order.push_front(member_name);

if (exported) {
#ifdef TOOLS_ENABLED
Expand Down Expand Up @@ -2385,6 +2390,7 @@ bool CSharpScript::_update_exports() {
StringName member_name = property->get_name();

member_info[member_name] = prop_info;
member_order.push_front(member_name);

if (exported) {
#ifdef TOOLS_ENABLED
Expand Down Expand Up @@ -3302,8 +3308,8 @@ Ref<Script> CSharpScript::get_base_script() const {

void CSharpScript::get_script_property_list(List<PropertyInfo> *p_list) const {

for (Map<StringName, PropertyInfo>::Element *E = member_info.front(); E; E = E->next()) {
p_list->push_back(E->value());
for (const List<StringName>::Element *E = member_order.front(); E; E = E->next()) {
p_list->push_back(member_info[E->get()]);
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/mono/csharp_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class CSharpScript : public Script {
#endif

Map<StringName, PropertyInfo> member_info;
List<StringName> member_order;

void _clear();

Expand Down