Skip to content

Instantly share code, notes, and snippets.

@paulloz
Last active Sep 30, 2021
Embed
What would you like to do?
Visual Studio Code and C# code completion and debugger for Godot

Visual Studio Code and C# code completion and debugger for Godot

Ok, this is a quick document to guide you through the setup of a Godot project in Visual Studio Code.
I'll assume you have a working C# environment installed. Note that on Linux, you will need to install Mono for everything to work fine.

1. Install the necessary extensions

First off, make sure you have the following extensions installed and active in Visual Studio Code:

At this point you should already be able to use code completion for C#, except for anything coming from the Godot namespaces.

completion_1

2. Create a new project in Godot

The next step is to actually create a project in Godot.

3. Generate the C# solution

In Godot's menus: go into Project > Tools > C#, and click on Create C# solution.

generate_solution

After a few seconds and some loading bars, you should see a new menu appear in the bottom dock. It opens the panel where you'll see build reports for the C# project.

new_menu

4. Build the project once

In the new panel, click on Build > Build Solution. Everything should go smoothly. After all, the project is empty. Once the build is done, let's proceed to the next step.

build_solution

5. (Re)Start Omnisharp in Visual Studio Code

Back in Visual Studio Code, open up the command palette (Ctrl+Shift+P), search for the OmniSharp: Restart omniSharp command and run it.

restart_omnisharp

It may ask you to choose a project, select the .sln option.

project_selection

/!\ It is very important that you do not click out this box without selecting anything. If you do so: do not panic and search for the OmniSharp: Select Project command in the palette.

select_project

Once you've selected your project and OmniSharp is properly started, the name of the project should appear in the lower left corner of Visual Studio Code. The small flame on its left is the icon for OmniSharp, it lights up when the service is busy.

status_bar

6. Go check everything work

Once all of this is done, everything should work fine.

completion_2

7. Bonus step, setting up the debugger

Head out to the Run and Debug menu in Visual Studio Code and you'll see a small link titled create a launch.json file.

create_launch_json

Click on it and a menu appears, asking you to select an environment. Choose C# Godot.

select_environment

Once it's done, the Run and Debug menu will change and you'll be able to start debugging with the Play in Editor button.

start_debugging


❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment