From c310ecce13aa9a88118ac032c08dc09faf134430 Mon Sep 17 00:00:00 2001 From: Paul Joannon Date: Sat, 23 Sep 2023 01:14:17 +0200 Subject: [PATCH] Fix captured variable serialization in delegates --- .../glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs index ef3c9c79d4d..7a88fea5f1f 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs @@ -207,7 +207,7 @@ namespace Godot foreach (FieldInfo field in fields) { - Type fieldType = field.GetType(); + Type fieldType = field.FieldType; Variant.Type variantType = GD.TypeToVariantType(fieldType); @@ -216,7 +216,7 @@ namespace Godot static byte[] VarToBytes(in godot_variant var) { - NativeFuncs.godotsharp_var_to_bytes(var, false.ToGodotBool(), out var varBytes); + NativeFuncs.godotsharp_var_to_bytes(var, godot_bool.True, out var varBytes); using (varBytes) return Marshaling.ConvertNativePackedByteArrayToSystemArray(varBytes); } @@ -483,7 +483,7 @@ namespace Godot if (fieldInfo != null) { - var variantValue = GD.BytesToVar(valueBuffer); + var variantValue = GD.BytesToVarWithObjects(valueBuffer); object? managedValue = RuntimeTypeConversionHelper.ConvertToObjectOfType( (godot_variant)variantValue.NativeVar, fieldInfo.FieldType); fieldInfo.SetValue(recreatedTarget, managedValue); @@ -799,7 +799,7 @@ namespace Godot return func(variant); if (typeof(GodotObject).IsAssignableFrom(type)) - return Convert.ChangeType(VariantUtils.ConvertTo(variant), type, CultureInfo.InvariantCulture); + return VariantUtils.ConvertTo(variant); if (typeof(GodotObject[]).IsAssignableFrom(type)) { @@ -818,7 +818,7 @@ namespace Godot } using var godotArray = NativeFuncs.godotsharp_variant_as_array(variant); - return Convert.ChangeType(ConvertToSystemArrayOfGodotObject(godotArray, type), type, CultureInfo.InvariantCulture); + return ConvertToSystemArrayOfGodotObject(godotArray, type); } if (type.IsEnum)