You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now this is a tough one. An EditorPlugin written in C# subscribes to a button via a lambda. If we change some C# file (outside of the plugin) and recompile the project, the subscription either gets lost or stays, depending on the captured variables of the lambda. If we capture a constant, it keeps working:
Weirdly enough, when I connect both buttons, one with the constant in the lambda, and the other with the variable in the lambda, none of them work after the rebuild, both now point to null!
Why is this a big problem
In some situations the captured variables in the lambdas are unavoidable. Lets say you have a list of buttons and need to know which one was pressed. When you make a C# plugin, you want it to function at all times in development, unless it is being changed. If you now program your gameplay logic in C#, every time you change something, the plugin breaks.
Maybe the much bigger problem here is the fact that the plugin is being recompiled at all. When nothing changed inside the addons folder, why would the plugin recompile after all.
Steps to reproduce
Connect a signal in a plugin to a lambda and a captured variable.
Enable the plugin
Change some C# file.
Recompile
Observe the errors when the signal is emitted.
You can use the reproduction project, which adds a button to the side of the spatial view. Press the button to emit the signal. Change something in any C# file, press build, and press the button again. Observe that the method works if the button is connected to a lambda with constants only, but does not work if connected to a captured variable.
Godot version
4.0.2 mono
System information
Windows 10
Issue description
Now this is a tough one. An EditorPlugin written in C# subscribes to a button via a lambda. If we change some C# file (outside of the plugin) and recompile the project, the subscription either gets lost or stays, depending on the captured variables of the lambda. If we capture a constant, it keeps working:
However, if we capture a variable in the lambda, upon changing a file outside the plugin and rebuilding the project, the signal now points to
null
.Weirdly enough, when I connect both buttons, one with the constant in the lambda, and the other with the variable in the lambda, none of them work after the rebuild, both now point to
null
!Why is this a big problem
In some situations the captured variables in the lambdas are unavoidable. Lets say you have a list of buttons and need to know which one was pressed. When you make a C# plugin, you want it to function at all times in development, unless it is being changed. If you now program your gameplay logic in C#, every time you change something, the plugin breaks.
Maybe the much bigger problem here is the fact that the plugin is being recompiled at all. When nothing changed inside the addons folder, why would the plugin recompile after all.
Steps to reproduce
You can use the reproduction project, which adds a button to the side of the spatial view. Press the button to emit the signal. Change something in any C# file, press build, and press the button again. Observe that the method works if the button is connected to a lambda with constants only, but does not work if connected to a captured variable.
Minimal reproduction project
EditorPluginRebuildTest.zip
The text was updated successfully, but these errors were encountered: