-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Expose signals and callbacks as C# events #15558
Comments
Small note: not all signals are also emitted as virtual calls and vice versa. You can still register to signals using |
@neikeq Isn't this done by now? |
No, this is not done yet. I would really like it to happen, but there are still some problems to settle first. Supposing we don't change the way signals and connections workThe situation would be like this. We have the following "signal" event:
Raising this event should not only call its delegates, but also
This can probably be fixed by making We also want The other option is to extend the way signals and connections.Connecting a signal from the engine would actually add a delegate to the event. I think it would fix Edit: One possible problem introduced. What about connections added before the script instance is created. |
One thing we can definitely do in the meantime is add an overload of Connect that replaces the target object and method name with a delegate. |
This seems to be now implemented judging from this progress report. Can you confirm this, @neikeq? |
Yes, this is implemented for signals in 6a85cdf. Note: The problem I described in my first comment was not resolved yet. Right now we still need |
Hey! Would be cool to have some option to pass Functions as an parameters into arguments of the Signals. For now there is Marshaling error |
awesome. Is there any documentation on how to implement this? the official docs still show the SignalAttribute + delegate method. |
@dimi3tron It's just an event with the Signal attribute, e.g.: [Signal]
event Action Pressed; Currently you need to use Keep in mind this is only available in 4.0 which is not released yet. |
Thx. For some reason I was under the impression it was already in the current build. Great to see these kinds of improvements, really makes Godot feel more like home for long time c# developers like myself. Excited for 4.0! |
Godot version:
master
/ 2ac2760OS/device including version:
Manjaro Linux 17.1-rc2
Issue description: (This issue is a feature request)
Currently, in order to receive various callback events, like when a node is added to the tree or receives an input, one needs to override relevant methods (i.e.
_EnterTree()
).However, in case of C# projects, some might prefer accessing them as events since it's more of an idiomatic way to implement an observer pattern. And the same can be said of signals like
Button.pressed
, for example.Maybe we can add additional events along with existing callback methods and signals to provide an alternative method for those who prefer a more idiomatic approach. Or, we might let users to choose whether to enable such a feature by using a conditional compilation symbol.
The text was updated successfully, but these errors were encountered: