Godot: New signal methods in C# are declared outside of its class, making the script invalid

Created on 8 May 2018  路  6Comments  路  Source: godotengine/godot

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:

  1. Create a button node.
  2. Attach a new C# script to this node.
  3. Select the button in the editor, choose Node -> Signals
  4. Select the "pressed()" signal and click connect.
  5. Choose the same button as the "Node to Connect." Leave everything default and hit connect.
  6. Notice that the new method is created outside of the class.

Example:

using Godot;
using System;

public class btn_move : Button
{
    public override void _Ready()
    {
    }
} //End of class


private void _on_Button_pressed()
{
    // Replace with function body
}

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.

bug confirmed editor mono usability

Most helpful comment

This depends on #12908 first before a fix can be added for C#.

All 6 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 (Object.connect), or uncheck Make Function in the signal connection dialog.

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 :)

Was this page helpful?
0 / 5 - 0 ratings