How to send parameter with built-in signals Godot 4 C#

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

I am migrating C# code to Godot 4.

Here is a line of Godot 3.5 code:

myButton.Connect("button_down", this, "_btnDown", new Godot.Collections.Array{24});

This code connects the button_down signal to the _btnDown(int num) function. It will also send the number 24 to the _btnDown(int num) function everytime the “myButton” is pressed.

How do I do the same thing in Godot 4?

:bust_in_silhouette: Reply From: LeslieS

Looks like that will send an array with a single element 24.
In any case this is (option 3 from the docs on connect) using GDScript. It should be very similar in c# and ignoring the array aspect:


You should be able to work it into c#. I think bind is the aspect you were missing.
It is possible that bind is not yet implemented in C# version.
Here is some workarounds


I tried this binding and it just doesn’t work. I think you are right. It may not need implemented in C# yet. That is really unfortunate.
I don’t want to mess with the workaround because I’ll just have to change the code again once binding is implemented.
Sadly, i feel like i just have to wait to migrate my project. It relies heavily on binding built in signals.

ondesic | 2022-12-20 13:12