Basics With Godot | Setting Up Godot C# With VS Code

Hey guys, today we are going to talk about how to set up Godot C# to work with Visual Studio and VS code! This is a very important part of using C# inside of Godot because using Godot’s internal editor is not very good sadly.

Getting Godot

Lets first get the mono version of godot, so lets go out to Godots Website.

Once we are there we need to pull down the mono version of Godot, this is a special version of godot that has mono built in. (mono is the c# compiler for Godot)

In this case we are going to pull down the 64 bit version. Now that we have it downloaded lets go ahead and get our other applications.

Setting up VS Code

First we need to head out to Microsoft VS Code Website.

Once we have it downloaded lets go ahead and install it. Go ahead and click on the installer. It will ask you to accept a license agreement so accept that (no one reads it anyway) and wait a while. Thankfully VS Code installs quickly.

Lets open up visual studio code and go out to our extensions so click on the little boxes stacked on top of each other.

From here lets go ahead and install C# tools for Godot and C# by Microsoft.

These will allow us to interact with godot using C# the C# addon by microsoft gives us the ability to understand and use c# and the tools for godot allows us to interact with the c# bindings thats godot offers.

Getting into Godot

First lets go and create our project so go ahead and create a new project in my case im calling it cSharpTestProject. After it opens lets go in and set up our editor settings so lets to go Editor -> Editor Settings. This will open up our editor settings.

Lets first go down to our text editor settigns and go to files and find the property Open Dorminant Script on Scene Change and lets set that to off.

Lets move down to the bottom of our categories and find Mono form here we will click on editor and go over to our external editor setting. Lets set that to Visual Studio Code.

At this point we can go ahead and go out to our project -> project settings and scroll all the way down to Mono and under Debugger Agent there is a check box we need to be sure is on called Wait For Debugger.

Finally lets go ahead and test our results. Lets create a scene and create a script on the main node. Under language lets have it set to C#. This will open up Visual Studio Code! Nice! We have it working so far! In our _Ready() function lets add a print function

GD.Print("Hello World")

Now that we have that set up lets go ahead and set a break point on our hello world print statement.

Next lets debug it click on the play bug icon and click create a launch debug file.

You will see a popup that asks you to set up your environment. Lets click on C# Godot

Sweet it stopped at our break point! This means we have it all working now!

Now that we have that working we can finally use C# with Visual Studio Code.

Conclusion

Well that was quite a ride! If your wondering why you would want to use C# be sure to check the comparison I did a while back on the speed differences with GD Script here, but that’s all I have for you guys today so thank you so much again for reading and ill see you all next time!

Companion Video

Leave a Reply

Your email address will not be published. Required fields are marked *