- Edited
Hi all, I'm trying to use a custom signal in C# but I'm having some problems.
I have a class NoteHandler
that defines a signal ShowNote. It looks like this:
public partial class NoteHandler : Node2D
{
[Signal]
public delegate void ShowNoteEventHandler(int input, double time);
}
And in my Player class, I want to Emit it with this line:
EmitSignal(NoteHandler.SignalName.ShowNote, 1, 1.0);
But I'm getting the error Can't emit non-existing signal "ShowNote" ... Condition "!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)" is true. Returning: ERR_UNAVAILABLE
meaning that the signal isn't properly defined. I've logged all the signals from both NoteHandler and Player, and NoteHandler by using this.GetSignalList
and NoteHandler.GetGodotSignalList
respectively, and NoteHandler does properly print out ShowNote, while Player does not. I assume this is some sort of access problem?
I've tried adding this method to NoteHandlers as well:
public void EmitShowNote(int input, double time)
{
this.EmitSignal(SignalName.ShowNote, input, time);
}
and emitting the signal by doing
NoteHandler noteHandler = new NoteHandler();
noteHandler.EmitShowNote(1, 1.0);
And although this does not throw an error, nothing happens despite me defining a callback on NoteHandler
to just print its arguments. They are in the same scene as well, so I am confused about what is going on. Any help is much appreciated, thanks!