Bläddra i källkod

Add ROS overload for Callable.Call

Joyless 3 månader sedan
förälder
incheckning
d956bcf749
1 ändrade filer med 14 tillägg och 2 borttagningar
  1. 14 2
      modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.cs

+ 14 - 2
modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.cs

@@ -79,13 +79,19 @@ namespace Godot
 
 
         private const int VarArgsSpanThreshold = 10;
         private const int VarArgsSpanThreshold = 10;
 
 
+        /// <inheritdoc cref="Call(ReadOnlySpan{Variant})"/>
+        public Variant Call(params Variant[] args)
+        {
+            return Call(args.AsSpan());
+        }
+
         /// <summary>
         /// <summary>
         /// Calls the method represented by this <see cref="Callable"/>.
         /// Calls the method represented by this <see cref="Callable"/>.
         /// Arguments can be passed and should match the method's signature.
         /// Arguments can be passed and should match the method's signature.
         /// </summary>
         /// </summary>
         /// <param name="args">Arguments that will be passed to the method call.</param>
         /// <param name="args">Arguments that will be passed to the method call.</param>
         /// <returns>The value returned by the method.</returns>
         /// <returns>The value returned by the method.</returns>
-        public unsafe Variant Call(params Variant[] args)
+        public unsafe Variant Call(scoped ReadOnlySpan<Variant> args)
         {
         {
             using godot_callable callable = Marshaling.ConvertCallableToNative(this);
             using godot_callable callable = Marshaling.ConvertCallableToNative(this);
 
 
@@ -115,12 +121,18 @@ namespace Godot
             }
             }
         }
         }
 
 
+        /// <inheritdoc cref="CallDeferred(ReadOnlySpan{Variant})"/>
+        public void CallDeferred(params Variant[] args)
+        {
+            CallDeferred(args.AsSpan());
+        }
+
         /// <summary>
         /// <summary>
         /// Calls the method represented by this <see cref="Callable"/> in deferred mode, i.e. during the idle frame.
         /// Calls the method represented by this <see cref="Callable"/> in deferred mode, i.e. during the idle frame.
         /// Arguments can be passed and should match the method's signature.
         /// Arguments can be passed and should match the method's signature.
         /// </summary>
         /// </summary>
         /// <param name="args">Arguments that will be passed to the method call.</param>
         /// <param name="args">Arguments that will be passed to the method call.</param>
-        public unsafe void CallDeferred(params Variant[] args)
+        public unsafe void CallDeferred(scoped ReadOnlySpan<Variant> args)
         {
         {
             using godot_callable callable = Marshaling.ConvertCallableToNative(this);
             using godot_callable callable = Marshaling.ConvertCallableToNative(this);