averageCOMRE create an export (I think it's [export]
), then compile, then see if it appears in the inspector.
The engine doesnt seem to recognize the c# files
DaveTheCoder indeed
Jesusemora i am sorry but i dont understand , can you please elaborate?
also the intellisense is not working
- Edited
averageCOMRE Try deleting *.csproj
, *.sln
and .godot/mono/
files/folders from your project folder, restart and rebuild C# solution via Project > Tools > C# > Crteate C# solution
i forgot to highlight this i.e. when i first created the c# file and tried opening it , there was a pop-up saying "failed to create c# project"
also , there is no file as .csproj , .sln or .godot/mono , i tried creating the c# solution , but , as stated before , it gave the same pop-up
averageCOMRE also , there is no file as .csproj , .sln or .godot/mono
Your vs code screenshot shows there in fact is .godot/mono
- Edited
oh my bad , but there is no file other than that , like the .csproj , .sln u were talking about
averageCOMRE Are you sure? I don't see the 'Build' button next to the 'Play' button in the Inspector. Show your working, post a screengrab of godot's Help->About window.
And fix all the typos in the script names while you're at it
averageCOMRE if you don't know how to use C# just use gdscript
. Have you followed the doc's instructions on how to use godot with C#?
you need an external editor, a godot extension for the editor, and the MONO version of godot, and you must know C# on its own, just having used C# with unity is not enough.
Then you have to BUILD the project in your code editor, and then you can use things like exports in godot if compilation was successful.
averageCOMRE also the intellisense is not working
and it never will. intellisense is for gdscript only. If you want to code in C# you have to do it in an external editor.
Jesusemora you need an external editor, a godot extension for the editor,
You actually don't need those things. C# scripts can be written in Godot's editor.
xyz ok, let's look at the docs so I don't say this from memory:
https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_basics.html
Godot bundles the parts of .NET needed to run already compiled games. However, Godot does not bundle the tools required to build and compile games, such as MSBuild and the C# compiler. These are included in the .NET SDK, and need to be installed separately.
In summary, you must have installed the .NET SDK and the .NET-enabled version of Godot.
you need the NET doodahs and a compiler, as well as an external editor and the NET version of godot.
C# support in Godot's built-in script editor is minimal. Consider using an external IDE or editor, such as Visual Studio Code or MonoDevelop. These provide autocompletion, debugging, and other useful features for C#. To select an external editor in Godot, click on Editor β Editor Settings and scroll down to Dotnet. Under Dotnet, click on Editor, and select your external editor of choice. Godot currently supports the following external editors:
Visual Studio 2022 Visual Studio Code MonoDevelop Visual Studio for Mac JetBrains Rider
external editor because godot supports gdscript only. Then it lists the steps to configure godot for each external editor.
Visual Studio CodeΒΆ
After reading the "Prerequisites" section, you can download and install Visual Studio Code (aka VS Code).
In Godot's Editor β Editor Settings menu:
Set Dotnet -> Editor -> External Editor to Visual Studio Code.
In Visual Studio Code:
Install the C# extension.
Note
If you are using Linux you need to install the Mono SDK for the C# tools plugin to work.
To configure a project for debugging, you need a
tasks.json
andlaunch.json
file in the.vscode
folder with the necessary configuration. An example configuration can be found here . In the launch.json file, make sure the program parameter in the relevant configuration points to your Godot executable, either by changing it to the path of the executable or by defining a GODOT4 environment variable that points to the executable. Now, when you start the debugger in Visual Studio Code, your Godot project will run.
Visual Studio (Windows only)ΒΆDownload and install the latest version of Visual Studio. Visual Studio will include the required SDKs if you have the correct workloads selected, so you don't need to manually install the things listed in the "Prerequisites" section.
While installing Visual Studio, select this workload:
.NET desktop development
In Godot's Editor β Editor Settings menu:
Set Dotnet -> Editor -> External Editor to Visual Studio.
Note
If you see an error like "Unable to find package Godot.NET.Sdk", your NuGet configuration may be incorrect and need to be fixed.
A simple way to fix the NuGet configuration file is to regenerate it. In a file explorer window, go to %AppData%\NuGet. Rename or delete the NuGet.Config file. When you build your Godot project again, the file will be automatically created with default values.
oh yeah, and the C# extension, you need a C# extension. And MONO SDK for the extension to work. Or maybe that's just for linux, which I'm on.
Warning
You need to (re)build the project assemblies whenever you want to see new exported variables or signals in the editor. This build can be manually triggered by clicking the Build button in the top right corner of the editor.
You will also need to rebuild the project assemblies to apply changes in "tool" scripts.
and here's the button for building the project.
Jesusemora I only said that you don't need an external editor to write C# scripts. Which is true.
Watch out not to overwhelm the OP with information torrents
Thank you very much for these tips everyone
spaceyjase
Here it is
- Edited
also i didnt follow the Documentation's instruction to setup C# with godot , i actually tried to follow the instruction from a video of this youtuber called Gamesfromscratch , here it is
Also , i *wasnt *able the tutorial completely , and in fact , the only way i found out that i could link godot to vs code through the editor settings was by accident ! And it worked fine .... until now .
Jesusemora
well it was the tasks.json part i was having a problem in when i was following gamesfromscratch's video , i think i should have paid heed to it
- Edited
I have installed an older version of godot ( godot 3..5.3) , and c# seems to be working fine there , although i dont know how to setup vs code there , i am more than willing to adjust
averageCOMRE Try to run a C# script in a fresh project, without any VSC involvement. That way you'll know if the issue is with Godot or with VSC setup.
well it did
i wrote a code which printed "hello world" [ GD.print( "Hello world" ) ], in the default text editor of godot , and it ran fine . so this means that there is problem with the setup of vs code , but please do keep in mind that i did this in godot 3.5.3