How to make a custom signal using C#?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hnuqweasd
:warning: Old Version Published before Godot 3 was released.

In GDscript you can do something like:

# some_node
signal my_signal

func signal_emitter():
    if something == true:
        emit_signal("my_signal")

#other_node

func signal_responder():
    get_node("some_node").connect("my_signal", self, "some_func")

func some_func():
    do_stuff()

How do you do this in C#? I’m guessing it has something to do with AddUserSignal and EmitSignal and someNode.Connect but trying this throws an error ‘Attempt to connect nonexistent signal… to method…’ so I’m guessing AddUserSignal is the wrong way to go about this…?

You should check Git discussions. Right now it’s not implemented and there is an open issue:

Signals issue

davidoc | 2017-11-02 17:25

Thanks :slight_smile: I can work around it for now

hnuqweasd | 2017-11-03 01:22

Should we prefer C# pattern (events) over Godot pattern (signals) ?

Alexande Daubricourt | 2018-06-28 18:28