Unity Intellisense with VSCode not suggesting/autofilling – C#

by
Ali Hasan
c# unity-game-engine visual-studio-code

Quick Fix: If you are using a newer version of the .NET Devkit than the one Unity is using, uninstall the newer version and install an older version that is compatible with Unity.

The Problem:

Intellisense is not working in VSCode for a Unity project. The console output shows errors related to the project file being in an unsupported format. How can this be resolved?

The Solutions:

Solution 1: Install the correct version of the .NET Devkit

The Unity project shows errors because the installed .NET Devkit version (4.8.1) is incompatible with Unity’s preferred version (4.7.1). To resolve this issue and enable Intellisense in VSCode, follow these steps:

  1. Uninstall the installed version of the .NET Devkit (4.8.1).
  2. Download and install version 4.7.1 of the .NET Devkit.

Once you install the correct version, the project should load successfully, and Intellisense will become available in VSCode.

Solution 2: Switch to the Stable Version of the C# Extension

To resolve the Intellisense issue, follow these steps:

  1. Open the Extensions tab in Visual Studio Code (VSCode).
  2. Search for the "C#" extension.
  3. Click the "Switch to Release Version" option for the C# extension.

This action changes the extension to the stable version, which is compatible with the .NET DevKit extension and allows Intellisense to work correctly.

Solution 4: Downgrade .Net Version to .Net 6.0

  • Uninstall .Net version 7.0
  • Switch to .Net 6.0 by installing .Net SDK 6.0
  • Restart VSCode
  • Unity should start importing the project Assets into VSCode again.
  • If Unity didn’t start importing Assets automatically, run Reimport All (Assets -> Reimport All)
  • Intellisense will start working after Reimport All.

Q&A

How do I convert the .csproj to a "traditional .NET Framework project" and still have it work with Unity?

Uninstall version 4.8.1 and install 4.7.1 instead.

What if I have tried uninstalling and reinstalling VSCode, updating the "Visual Studio Code" Extension in Unity, installing the .NET Devkit, checking that VSCode is selected in Unity as the external script editor as well as turning off Omnisharp Modern NET usage?

Manually select the version in Visual Studio Code.

I believe the issue lies within the unity packages and not the vs code extensions. What should I do?

Remove the "Engineering" suite, install the "Visual Studio Editor 2.0.22" package, select vs code as an option with the version in the external tools window, and regenerate the project files.

Video Explanation:

The following video, titled "Fix Visual Studio Code Unity IntelliSense AutoComplete ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

This has been bugging me for years. I finally sat down and settled things by staring Unity and vscode deep in its eyes.