Fix getting properties state when reloading C#

When reloading C# classes and keep their properties values they are
retrieved and stored in a state list.
Retrieving the properties was only getting the fields of the C# class
and not inherited fields so those properties values were lost on reload.
Now we also try to find the field in the parent classes.

(cherry picked from commit 907e709f9d)
This commit is contained in:
Raul Santos 2021-12-28 19:11:10 +01:00 committed by Rémi Verschelde
parent 51f99586ee
commit 99353a2aee
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -1570,9 +1570,19 @@ void CSharpInstance::get_properties_state_for_reloading(List<Pair<StringName, Va
ManagedType managedType; ManagedType managedType;
GDMonoField *field = script->script_class->get_field(state_pair.first); GDMonoField *field = nullptr;
if (!field) GDMonoClass *top = script->script_class;
while (top && top != script->native) {
field = top->get_field(state_pair.first);
if (field) {
break;
}
top = top->get_parent_class();
}
if (!field) {
continue; // Properties ignored. We get the property baking fields instead. continue; // Properties ignored. We get the property baking fields instead.
}
managedType = field->get_type(); managedType = field->get_type();