From a4c0b3746455a6e6f197bc98cd56bb6a037526f3 Mon Sep 17 00:00:00 2001 From: Asa Sprow Date: Wed, 16 Oct 2024 12:00:25 -0600 Subject: [PATCH] add C# documentation for connecting to gdscript signal with parameters --- tutorials/scripting/cross_language_scripting.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tutorials/scripting/cross_language_scripting.rst b/tutorials/scripting/cross_language_scripting.rst index 8b193e1b8..8a057c122 100644 --- a/tutorials/scripting/cross_language_scripting.rst +++ b/tutorials/scripting/cross_language_scripting.rst @@ -19,6 +19,7 @@ The following two scripts will be used as references throughout this page. var my_field: String = "foo" signal my_signal + signal my_signal_with_params(msg: String, n: int) func print_node_name(node: Node) -> void: print(node.get_name()) @@ -34,6 +35,9 @@ The following two scripts will be used as references throughout this page. func my_signal_handler(): print("The signal handler was called!") + func my_signal_with_params_handler(msg: String, n: int): + print_n_times(msg, n) + .. code-tab:: csharp using Godot; @@ -43,6 +47,7 @@ The following two scripts will be used as references throughout this page. public string myField = "bar"; [Signal] public delegate void MySignalEventHandler(); + [Signal] public delegate void MySignalWithParamsEventHandler(string msg, int n); public void PrintNodeName(Node node) { @@ -69,6 +74,11 @@ The following two scripts will be used as references throughout this page. { GD.Print("The signal handler was called!"); } + + public void MySignalWithParamsHandler(string msg, int n) + { + PrintNTimes(msg, n); + } } Instantiating nodes @@ -213,6 +223,8 @@ defined in GDScript: my_csharp_node.MySignal.connect(my_signal_handler) + my_csharp_node.MySignalWithParams.connect(my_signal_with_params_handler) + Connecting to GDScript signals from C# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -223,6 +235,8 @@ because no C# static types exist for signals defined by GDScript: myGDScriptNode.Connect("my_signal", Callable.From(MySignalHandler)); + myGDScriptNode.Connect("my_signal_with_params", Callable.From(MySignalWithParamsHandler)); + Inheritance -----------