summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgnacio Roldán Etcheverry <neikeq@users.noreply.github.com>2021-08-04 00:22:42 +0200
committerGitHub <noreply@github.com>2021-08-04 00:22:42 +0200
commitd5e13a036f9bfcba8ea1bfb6f4eb603482a74a8f (patch)
tree36f5e747dd2cb58fcde351f34708917914c7e7d1
parent769de0c35f10780edc1a670b09f63fc730fefc39 (diff)
parentad460cde7988e42acd4ec8d7c35d9c50f7c063a7 (diff)
downloadredot-engine-d5e13a036f9bfcba8ea1bfb6f4eb603482a74a8f.tar.gz
Merge pull request #51020 from raulsntos/csharp-print-methods
Simplify C# print methods
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs20
1 files changed, 15 insertions, 5 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs
index f8f5e27397..a6f7a80d64 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs
@@ -28,6 +28,16 @@ namespace Godot
return (real_t)Math.Exp(db * 0.11512925464970228420089957273422);
}
+ private static object[] GetPrintParams(object[] parameters)
+ {
+ if (parameters == null)
+ {
+ return new[] { "null" };
+ }
+
+ return Array.ConvertAll(parameters, x => x?.ToString() ?? "null");
+ }
+
public static int Hash(object var)
{
return godot_icall_GD_hash(var);
@@ -65,7 +75,7 @@ namespace Godot
public static void Print(params object[] what)
{
- godot_icall_GD_print(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null"));
+ godot_icall_GD_print(GetPrintParams(what));
}
public static void PrintStack()
@@ -75,22 +85,22 @@ namespace Godot
public static void PrintErr(params object[] what)
{
- godot_icall_GD_printerr(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null"));
+ godot_icall_GD_printerr(GetPrintParams(what));
}
public static void PrintRaw(params object[] what)
{
- godot_icall_GD_printraw(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null"));
+ godot_icall_GD_printraw(GetPrintParams(what));
}
public static void PrintS(params object[] what)
{
- godot_icall_GD_prints(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null"));
+ godot_icall_GD_prints(GetPrintParams(what));
}
public static void PrintT(params object[] what)
{
- godot_icall_GD_printt(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null"));
+ godot_icall_GD_printt(GetPrintParams(what));
}
public static float Randf()