michaelhly's blog

logs.blobs.lol/four

I'm not sure if I can't read or just can't follow instructions, but the steps here on setting up Unity with VSCode did not seem comprehensive. At the time of writing this blog post, the VSCode docs were last updated on 5/26/2022.

Here is everything I had to do to set up VSCode properly, so I'm not writing C# scripts for my Unity app like a blind person.

  1. Install the .NET SDK and Mono. Then, configure my shell profile and ensure that Mono's /bin folder is added to my environment's PATH variable:
-export PATH= ...
+export MONO_HOME=/Library/Frameworks/Mono.framework/Home
+export PATH=$MONO_HOME/bin:$PATH
  1. Run these commands to install Microsoft.Unity.Analyzers:
curl -sSfL https://www.nuget.org/api/v2/package/Microsoft.Unity.Analyzers/1.14.0 -o microsoft.unity.analyzers.1.14.0.nupkg
ditto -x -k microsoft.unity.analyzers.1.14.0.nupkg microsoft.unity.analyzers.1.14.0
rm -rf microsoft.unity.analyzers.1.14.0.nupkg
  1. Create an omnisharp.json file at the root folder of my project with:
{
  "RoslynExtensionsOptions": {
    "EnableAnalyzersSupport": true,
    "LocationPaths": ["./microsoft.unity.analyzers.1.14.0"]
  }
}
  1. Install the Visual Studio Code Editor package via Unity's package manager: Visual Studio Code Editor Package

  2. Regenerate project files in Unity: Regenerate button

  3. Open VSCode and install the C# VSCode extension.

I ended up installing v1.24.4 of the omnisharp-vscode extension instead of the latest, but I'm not sure if this mattered ... here are steps to do it for anyone curious:

curl -sSfL https://github.com/OmniSharp/omnisharp-vscode/releases/download/v1.24.4/csharp-1.24.4-darwin-arm64.vsix -o csharp-1.24.4-darwin-arm64.vsix
code --install-extension csharp-1.24.4-darwin-arm64.vsix
rm -rf csharp-1.24.4-darwin-arm64.vsix
  1. In VSCode, toggle these settings for the C# extension:
"omnisharp.useModernNet": false,
"omnisharp.useGlobalMono": "always"

Lol, I hope I didn't end up missing any steps ...

#bloblogs