Skip to content

Instantly share code, notes, and snippets.

@dariusf
Last active August 2, 2023 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dariusf/73653d1c88623b85d4d2f2383eb719ce to your computer and use it in GitHub Desktop.
Save dariusf/73653d1c88623b85d4d2f2383eb719ce to your computer and use it in GitHub Desktop.
Godot + C# + VSCode (macOS)

Updated July 2022.

Install system dependencies:

brew install --cask mono-mdk dotnet-sdk godot-mono
brew install mono
$ which dotnet msbuild mono
/usr/local/bin/dotnet
/Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild
/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono

Start Godot and create a project (e.g. $HOME/godot/hello).

Add a C# script to a node. This should generate hello.sln and hello.csproj files.

Set Editor > Editor Settings > Mono > Editor, so VSCode will be started when double-clicking script files.

Over to VSCode. Install the following extensions:

Open the project:

code $HOME/godot/hello

Uncheck OmniSharp: Use Modern Net or add this to your settings.

"omnisharp.useModernNet": false

Follow the prompts to restart OmniSharp.

At this point, IntelliSense should work for standard types and namespaces, e.g. List and System.Collections.Generic. If it doesn't, open the Output view and look at the C# and OmniSharp Log sections, and try to fix the errors there.

Once basic IntelliSense is working, start Godot in a separate terminal.1

/Applications/Godot_mono.app/Contents/MacOS/Godot --path "$HOME/godot/hello" -e

Click Build in the top-right corner.

Switch back to VSCode, Restart OmniSharp, and IntelliSense should work for Godot APIs like GD.Print.2

Debugging seems to just work. Select View: Show Run and Debug and click Play in Editor on the left.

Other resources:

Footnotes

  1. Godot invokes msbuild, so this is just to ensure it is started in the appropriate environment. Alternatively, select Godot Tools: Open workspace with Godot editor from the command palette after configuring the path to the editor in the workspace settings.json, and this will be done for you in a terminal in VSCode.

    "godot_tools.editor_path": "/Applications/Godot_mono.app/Contents/MacOS/Godot"
    
  2. In the status bar, you should see a flame icon indicating "OmniSharp server is running", and a "Connected" section indicating the GDScript language server (provided by Godot itself) is running.

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