summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZae <zaevi@live.com>2024-03-21 23:55:44 +0800
committerZae <zaevi@live.com>2024-03-21 23:55:44 +0800
commit833a03fbf6605e6e86e69870b654656ced6df824 (patch)
treef9620255bc465895881ddf73d7dbd264d377cb61
parentfe01776f05b1787b28b4a270d53037a3c25f4ca2 (diff)
downloadredot-engine-833a03fbf6605e6e86e69870b654656ced6df824.tar.gz
C#: Fix errors when creating Variant from null array
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs21
1 files changed, 18 insertions, 3 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
index 464b517428..94609984ac 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
@@ -235,13 +235,28 @@ namespace Godot.NativeInterop
}
public static godot_variant CreateFromSystemArrayOfStringName(Span<StringName> from)
- => CreateFromArray(new Collections.Array(from));
+ {
+ if (from == null)
+ return default;
+ using var fromGodot = new Collections.Array(from);
+ return CreateFromArray((godot_array)fromGodot.NativeValue);
+ }
public static godot_variant CreateFromSystemArrayOfNodePath(Span<NodePath> from)
- => CreateFromArray(new Collections.Array(from));
+ {
+ if (from == null)
+ return default;
+ using var fromGodot = new Collections.Array(from);
+ return CreateFromArray((godot_array)fromGodot.NativeValue);
+ }
public static godot_variant CreateFromSystemArrayOfRid(Span<Rid> from)
- => CreateFromArray(new Collections.Array(from));
+ {
+ if (from == null)
+ return default;
+ using var fromGodot = new Collections.Array(from);
+ return CreateFromArray((godot_array)fromGodot.NativeValue);
+ }
public static godot_variant CreateFromSystemArrayOfGodotObject(GodotObject[]? from)
{