-
-
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
New signal methods in C# are declared outside of its class, making the script invalid #18721
Comments
I find that this is still an issue in 3.0.6 |
This depends on #12908 first before a fix can be added for C#. |
Just a quick note that I can still see this in 3.2.3 RC6. |
Can anyone tell me how to connect the signals to an existing method without it creating a new function or at least how I can work around this ? |
@BenBausch You can either connect the signal by code ( Alternatively, just cut and paste the code snippet that was erroneously added at the end of the file and move it to the right place. |
I don't have a 'Make function' option in the signal connection dialog. Cutting and pasting the code snipped will give me an error because it can not find the function anymore. Thanks for the answer anyway! I will give the gdscript version of godot a shot since it seems less buggy to me :) |
I use Rider as external editor. In this case, the code is not generated at all. Even not below the class. |
A workaround for the issue of the code not getting generated at all is mentioned in #23208, which is closed now. Basically, method generation for signals doesn't work when using an external editor. The workaround is to have the built-in Godot editor as the default (Editor > Editor Settings... > Text Editor > External > Use External Editor unchecked). Once you click 'Connect' in the Connect A Signal to a Method dialog box, go to the editor and save the script. Then you can go to your external editor and the method will be there. An issue related to this is that the new method gets created outside of the class. So you have to cut/paste the method into the class. |
Following the workaround(s) detailed here does not solve the issue. I can produce the function outside of the class. However, after the function is dragged into the class, the signal fails to call the function. |
I personally prefer the editor to do nothing to the C# code file, but save the generated code snip to the clip board. I can then paste the function signature to where I want, or do nothing if the method already exists. Hope there can be some option to enable that. |
This is still in an issue in 4.2.1! |
This comment was marked as off-topic.
This comment was marked as off-topic.
I'm using v4.2.2 Stable (win64 if that matters here) and it's still an issue. I tried following the 2D game tutorial in Godot's docs until I came to this section of the HUD page. For context, there's a already a function in the project's Main script called
The HUD script's I apologize for coming across as bitter in this comment, I'm just really frustrated that I keep finding bugs that hurt my workflow. I get Godot's team has GDScript to take care of, but man. |
It would be nice to have a switcher to just dont generate the function at all. |
There used to be one in Godot 3.1 and earlier, but it seems it was removed in 3.2 when redesigning this dialog: But for the record, this was "fixed" in 4.3 by disabling callback generation for C# in #87952. I'm keeping this issue open for now as it's a common problem users run into, but we can close it once 4.3 is released. It's not a perfect solution of course as it still requires users to write the C# callback manually in their class, but it's proving pretty difficult to find a way to insert code in the C# class at the right location, that would support external editors too. |
Bugsquad edit: This long standing issue is still valid as of Godot 4.2. It doesn't need further confirmation, but feel free to 👍 the OP to confirm it affects you. Any help welcome to solve this, it's something the .NET team is having difficulty fixing properly, but it's recognized as a major usability issue.
Godot version:
3.0.3 rc1 Mono Build
Issue description:
When using the editor to connect a signal to a C# script, the new method declaration is added to the end of the file, and outside of the class. It should instead add the new method just before the final closing brace.
Steps to reproduce:
Example:
This is a low priority issue as the easy workaround is to just move the closing brace of the class, but this creates invalid code and could be confusing.
The text was updated successfully, but these errors were encountered: