-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to add custom signals to nodes from the editor #3655
Comments
Why? This is perfect case to use inheritance. |
This can make the code more confusing and increase the refactoring time. |
Even if OP's use case can be solved the other way, there is a ton of use cases where this would be very helpful. |
How is 3-line script confusing and increases refactoring time? (you don't need Stand-alone signal is useless without a code that will emit it. In your example, you can't connect
Name one that doesn't require any kind of script. |
Obviously all of those require a script, but being able to connect things without having to type a laundry list of blah.connect(ble) would be wonderful. |
Unless I misunderstand something, the proposal is about being able to declare a signal without using a script. Any signal you add to script will appear in the connection dock and you can connect it from editor. You can't emit the signal without script (unless you connect other signal to
But you can do that already... |
If I can, either that wasn't the case in 3.3 or it was bugged. (I haven't used 3.4 much so I might have missed an improvement there) |
Ah. Never noticed custom signals showed there, but there is one case when you can't connect them this way - when the source and target are in different scenes (can happen in large enough projects) |
That's unrelated to this proposal though. |
Should I open a new proposal then? To me, it is sorta related... |
This proposal is about creating signals in connections dialog without needing to use a script. Yours is different. Also no idea how you imagine it would work, because if you have 2 completely separate scenes, there is no way for one scene to know about the other one, so you can't connect them. Unless you instance both of them in a parent scene, in which case connecting from editor is already possible. But maybe you have some idea, so feel free to open a new proposal. |
If I only want to create a signal, why do I need to create a script( = file) for each node?
Like groups, isn't it?
For example, a node has signals s1, s2, s3 and I want s1 and s2 to trigger/emit s3.
I agree it may look strange and confusing, but what makes it wrong? |
The editor will look up signals in the node's classes and script is part of that. Adding a signal to node without a script is like adding a method or a variable without a script.
Signals are designed to be emitted by the node that declares them. It helps decoupling nodes. Doing otherwise is technically not wrong, but just goes against their design. Also groups are entirely different concept. You can add a group that will be used only by other nodes. Actually, if you plan to add a signal to a node, but only emit it from other nodes, so that other connected nodes can receive it, you could as well use a group.
How exactly are you planning to emit s1 and s2 without a script? There is always a script somewhere that emits the signal. Except for the built-in signals, but as I said, it won't work in all cases. You can't connect e.g. |
Yea, connect to emit_signal("s1"/"s2") 4
Will #762 solve it? |
Not really, you can't both bind and unbind arguments. |
closing in favor of inheritance and due to implementation difficulties |
Describe the project you are working on
Plugins
Describe the problem or limitation you are having in your project
I have cases when I would like to add my own signals to any node in a scene from the editor (not from a script).
For example I created a scene called
InputButton
When I press the button, the
ConfirmationDialog
withLineEdit
pops up.I find this controls combination quite frequent in my code so I decided to make it a scene so that I could easily reuse it (add instances of the scene anywhere).
In
InputButton
node I want to create a signalconfirmed
, that would be emitted when I type something inLineEdit
and press Enter or pressConfirmationDialog
Ok
button.The problem is I don't want to create the signal from a script attached to
InputButton
, because perhaps I will set another script on it (in order to create another abstraction); I don't want to use script inheritance in this case.The signal should be "static" (?), I should be able to use it from the editor.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
An ability to add custom signals to nodes from the editor would solve the problem.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
There is Node dock with Signals tab.
From there one could add signals to any node of any scene, without the need to create a script for it.
If this enhancement will not be used often, can it be worked around with a few lines of script?
it can't
Is there a reason why this should be core and not an add-on in the asset library?
I don't think this is possible with a plugin
The text was updated successfully, but these errors were encountered: