Skip to content
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

Step by step: Using signals shows wrong name for method in C#, adds outside of class #8224

Open
thettenhausen opened this issue Oct 11, 2023 · 2 comments
Labels
area:getting started Issues and PRs related to the Getting Started section of the documentation bug topic:dotnet

Comments

@thettenhausen
Copy link

Godot 4.1.2

In the tutorial for signals the code snippet for C# shows a method being addd called OnButtonPressed, but the engine actually needs a method called on_button_pressed even in C# (and correctly names it). Unfortunately it places it at the end of the file, not inside the class, so it is outside the {}. Was a bit confusing for me since that was when I broke the project for completely unrelated reasons in the filesystem and tried to restore it, but the tutorial send me in the wrong direction. After completely starting this part over from scratch I noticed the discrepancy.

The tutorial should have the correct name in the snippet. If the engine cannot place the code correctly in the wizard maybe add a notice that it needs to be moved before the closing bracket?

Page with issue: https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html

@DanTulovsky
Copy link

Related to this, is there a page that lists the C# equivalents to these kinds of functions?

@raulsntos
Copy link
Member

In the tutorial for signals the code snippet for C# shows a method being addd called OnButtonPressed, but the engine actually needs a method called on_button_pressed even in C# (and correctly names it)

The engine doesn't require any specific naming convention, you are free to name the signal callback however you want. The convention in GDScript is to call it on_button_pressed and in C# the convention is OnButtonPressed so that's what we use in the examples.

You likely called the method on_button_pressed when connecting to the signal, since that's the default if you don't change it, we mention the difference in the naming convention in this documentation page but maybe it's not clear enough.

Unfortunately it places it at the end of the file, not inside the class, so it is outside the {}.

There's currently 2 known bugs related to this:

Related to this, is there a page that lists the C# equivalents to these kinds of functions?

All the differences between GDScript and C# should be mentioned in the C# API differences to GDScript documentation page.

@Piralein Piralein added topic:dotnet area:getting started Issues and PRs related to the Getting Started section of the documentation labels Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:getting started Issues and PRs related to the Getting Started section of the documentation bug topic:dotnet
Projects
None yet
Development

No branches or pull requests

4 participants