From 5254b28632a3ea212ae69c86cc737768f26b9e12 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Tue, 28 Dec 2021 18:28:01 +0100 Subject: [PATCH] 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. --- modules/mono/csharp_script.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 0ceb45d4255..aa24f59fdbc 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1762,7 +1762,16 @@ void CSharpInstance::get_properties_state_for_reloading(Listscript_class->get_field(state_pair.first); + GDMonoField *field = nullptr; + 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. }