Fix captured variable serialization in delegates

This commit is contained in:
Paul Joannon 2023-09-23 01:14:17 +02:00
parent f6a78f83aa
commit c310ecce13
No known key found for this signature in database
GPG key ID: C12F69B0AD0390DD

View file

@ -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<GodotObject>(variant), type, CultureInfo.InvariantCulture);
return VariantUtils.ConvertTo<GodotObject>(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)