this is the code I have currently to load my game without error.
however I also want the method to be called with ‘Param1’ as the parameter, in gdscript I can just type the function and give what ever parameter directy but I can’t figure out how to use these callables in c# with custom parameters.
You can also create an Action, which can use any variable or value available in its current scope, and then create a Callable from it. In that way, you can do practically whatever you want without being tied to the limitations of Callable.
Hello, I’m doing exactly as your example but I’m getting the error Callable.generics.cs:20 @ void Godot.Callable.<ThrowIfArgCountMismatch>g__ThrowArgCountMismatch|0_0(int, int, string): System.ArgumentException: Invalid argument count for invoking callable. Expected 0 arguments, received 1. (Parameter 'args'), do you know what could be the cause?
my code
public void Init()
{
CardState child = GetNode<CardState>("CardUI");
void myAction() { OnTransitionRequested(child, child.state); }
child.Connect(CardState.SignalName.TransitionRequested, Callable.From(myAction));
}
public void OnTransitionRequested(CardState child, int state)
{
GD.Print("OnTransitionRequested");
}
public override void OnGuiInput(InputEvent inputEvent)
{
if (inputEvent.IsActionPressed("left_click"))
{
int toState = (int)State.CLICKED;
EmitSignal(CardState.SignalName.TransitionRequested, toState);
}
}