provide a modern way to create signal dynamically #13135
exhaust-pipe
started this conversation in
Scripting
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've recently been trying to create signals dynamically. The current method seems to be a two-step process: first, use
Object.add_user_signal("my_signal")
, and then create a reference to it withSignal(my_object, "my_signal")
to get a usable Signal instance. This was the solution I found on Reddit (What is the constructor of the Signal class useful for?).As a user in that thread pointed out, if it's possible to do this in multiple lines, it would be much better for Godot to provide a direct way to create a new signal. (he came up with the idea of a new Signal constructor)
My suggestion is to make
Object.add_user_signal()
return a Signal instance. This would turn a workaround into a clean, one-line method call:var new_signal = my_object.add_user_signal("my_dynamic_signal")
This would be a great improvement for anyone working with dynamic signals.
Beta Was this translation helpful? Give feedback.
All reactions