Monday, 13 July 2026

How to Set Up VS Code for Unity: Fix the Editor, Extensions, and IntelliSense

VS Code and Unity have a complicated relationship. Out of the box, VS Code does not know Unity exists. You open a C# script and get zero autocomplete, zero error highlighting, and zero ability to tell which methods are valid Unity API calls and which you are inventing. It looks like a fancy Notepad. Most people at this point assume they did something wrong or that VS Code just does not work for Unity.

Nothing is wrong. It just needs to be configured.

I switched from Visual Studio to VS Code about two years into working with Unity. Visual Studio is fine, but it is enormous — a 10GB install for a tool I mostly used to write C# and occasionally debug. VS Code is 300MB, starts in two seconds, and once it is configured correctly for Unity it does everything I actually needed from the full IDE. This guide is the setup I wish had existed when I made that switch.



Why VS Code for Unity Development

Visual Studio is the default suggestion Unity makes when you install it. For many developers, especially on Windows, that is a reasonable choice. Visual Studio has deep Unity integration, excellent debugging, and it works correctly out of the box with no configuration.

VS Code makes sense when:

  • You want a faster, lighter editor that does not take 30 seconds to open.
  • You also write in JavaScript, Python, or other languages and want one editor for everything.
  • You are on a machine where a full Visual Studio install would eat significant disk space.
  • You prefer VS Code's UI, extensions ecosystem, or Git integration over Visual Studio's.

JetBrains Rider is the third main option and is honestly the best Unity editor if you can justify the cost. It has the deepest Unity-specific code analysis of anything available — it understands Unity lifecycle methods, inspector serialization rules, and common performance mistakes in ways neither VS Code nor Visual Studio do out of the box. If you are a professional developer and $72 per year is not a problem, try Rider. For everyone else, VS Code is the free alternative worth learning to configure properly.



What You Need Before Starting

  • VS Code — download from code.visualstudio.com. The User install (not System) is fine for most people.
  • .NET SDK — version 8.0 or later from dotnet.microsoft.com. This is what actually powers C# IntelliSense. VS Code does not include it.
  • Unity 2021 LTS or newer — the configuration steps in this guide apply to Unity 2021 through Unity 6.

The .NET SDK is the step most beginner tutorials skip, which is exactly why IntelliSense silently fails for so many people. VS Code's C# extensions need the .NET SDK to analyze code. Without it, you get syntax highlighting and nothing else.

Part 1: Essential Extensions

Open VS Code and go to the Extensions panel (the square icon in the left sidebar, or Ctrl+Shift+X). Install these in order.

1. C# Dev Kit (Microsoft)

This is the main extension. It replaced the old OmniSharp-based C# extension as the recommended setup in 2023 and is what Microsoft actively develops and supports. It includes IntelliSense, code navigation, refactoring tools, and basic debugging for C#.

Search for C# Dev Kit, published by Microsoft. Installing it also automatically installs the base C# extension and the .NET Runtime Install Tool as dependencies.

2. Unity (Unity Technologies)

The official Unity extension adds Unity-specific features that C# Dev Kit does not know about: Unity API documentation on hover, quick access to Unity documentation, and better handling of Unity's non-standard project structure (the fact that Unity generates its own .csproj files rather than you managing them manually).

Search for Unity, published by Unity Technologies — not third-party Unity extensions from other publishers.

3. GitLens (GitKraken) — Optional but Recommended

If you are following the Git guide from this series, GitLens is worth adding. It shows inline blame information, a visual commit history, and branch visualization directly inside VS Code without switching to a terminal. Not essential, but it makes the Git workflow from the previous guide significantly more visual.

Extensions Worth Skipping

The VS Code marketplace has several older Unity-related extensions from third-party publishers that were useful before the official Unity extension existed. Most of them conflict with the official extension or duplicate its features with worse implementations. If you already have Debugger for Unity or Unity Code Snippets installed from an older setup, disable them — the official Unity extension covers both.



Part 2: Configure Unity to Use VS Code

Installing the extensions is half the work. Unity also needs to be told to use VS Code as its external script editor, or double-clicking a script in Unity will open it in the wrong editor.

  1. Open Unity and go to Edit > Preferences (Windows) or Unity > Preferences (Mac).
  2. Click External Tools in the left panel.
  3. In the External Script Editor dropdown, select Visual Studio Code.
  4. Click Regenerate project files.

The "Regenerate project files" step is important. Unity generates .csproj files that tell VS Code which files belong to the Unity project and which .NET APIs are available. Without regenerating these, VS Code does not know where the Unity API definitions live and IntelliSense will not work even with all the right extensions installed.

After this, double-clicking any C# script in Unity's Project window should open it directly in VS Code with the correct project context loaded.

Part 3: Fixing IntelliSense When It Does Not Work

This is the most common problem people hit after doing everything above correctly. IntelliSense works partially — maybe it knows about standard C# classes but does not recognize UnityEngine.MonoBehaviour, or it highlights using UnityEngine as an error even though the script compiles in Unity.

Almost every instance of this problem comes from one of four causes:

Cause 1: The .NET SDK is Missing or the Wrong Version

Open a terminal and run:

dotnet --version

If this returns an error or a version below 6.0, install or update the .NET SDK from dotnet.microsoft.com. Restart VS Code after installing.

Cause 2: Unity's Generated .csproj Files Are Stale or Missing

Go back to Unity, open Preferences > External Tools, and click Regenerate project files again. Then close VS Code completely (not just the window — quit the application) and reopen the project folder. VS Code needs a fresh start to pick up newly generated project files.

Cause 3: VS Code Opened the Wrong Folder

VS Code needs to be opened at the project root — the folder containing the Assets, Packages, and ProjectSettings folders. If you open VS Code from a subfolder (like directly inside Assets), it cannot find the .csproj files and IntelliSense breaks.

The fastest fix: in Unity, go to Assets > Open C# Project. This opens VS Code at the correct root folder automatically.

Cause 4: OmniSharp Is Conflicting With C# Dev Kit

If you have an older VS Code setup that used the original C# extension with OmniSharp, and you installed C# Dev Kit on top of it without removing the old configuration, the two can conflict. Check your VS Code settings (File > Preferences > Settings, then search for "omnisharp") and disable OmniSharp if it appears as an active option. C# Dev Kit does not use OmniSharp.



Part 4: Debugging Unity Scripts in VS Code

The Unity extension enables attaching the VS Code debugger to a running Unity instance, which lets you set breakpoints in your C# scripts and inspect variables at runtime — the same debugging workflow you get in Visual Studio, without needing the full Visual Studio install.

Setting Up the Debug Configuration

  1. In VS Code, click the Run and Debug icon in the left sidebar (the play button with a bug icon), or press Ctrl+Shift+D.
  2. Click create a launch.json file.
  3. Select Unity Debugger from the environment list.

VS Code creates a .vscode/launch.json file in your project with the correct configuration for attaching to Unity. It looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Unity",
            "type": "unity",
            "request": "attach"
        }
    ]
}

Using the Debugger

  1. Set a breakpoint by clicking in the left margin of any line in a C# script — a red dot appears.
  2. Press Play in Unity to start the game.
  3. In VS Code, press F5 or click the green play button in the Run and Debug panel to attach the debugger.
  4. When Unity executes the line with your breakpoint, the game pauses and VS Code shows the current variable values, call stack, and lets you step through code line by line.

The first time I used the VS Code Unity debugger instead of relying on Debug.Log() to diagnose a bug, I fixed something in about three minutes that had taken me forty-five minutes of log-statement-hunting the previous day. Being able to see every variable's actual value at the exact moment the bug occurs, rather than guessing which ones to log and rerunning repeatedly, is a different category of debugging entirely.

Part 5: Useful Settings to Configure

Open VS Code settings with Ctrl+, (comma) and search for each of these.

Format On Save

"editor.formatOnSave": true

Automatically formats your code every time you save. With the C# Dev Kit handling formatting, this keeps indentation and brace style consistent without having to think about it.

Auto Save

"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000

Saves files automatically one second after you stop typing. Useful for Unity specifically because Unity detects script changes by watching the file system — unsaved changes in VS Code are invisible to Unity until the file is actually written to disk.

Exclude Unity-Generated Files From Search

"search.exclude": {
    "**/Library": true,
    "**/Temp": true,
    "**/obj": true,
    "**/Logs": true
}

Unity generates enormous Library and Temp folders that VS Code's search would otherwise crawl through. Excluding them makes project-wide search dramatically faster and prevents confusing results from auto-generated files appearing in your search results.

File Associations for Unity-Specific File Types

"files.associations": {
    "*.asmdef": "json",
    "*.asmref": "json"
}

Unity's .asmdef and .asmref files are JSON but VS Code does not recognize them as such by default. This makes them open with JSON syntax highlighting and formatting instead of plain text.



A Real Example: The Daily Workflow

Here is what working on a Unity project in VS Code looks like once everything is configured.

You double-click a script in Unity's Project window. VS Code opens at the project root with the file focused, IntelliSense loads the Unity API context within a few seconds, and you start writing. Typing GetComponent< shows you every component type in the project. Typing Physics. shows every method in Unity's Physics class with documentation on hover. Ctrl+clicking any Unity method takes you to its definition or documentation.

When something breaks, you set a breakpoint on the suspicious line, press Play in Unity, press F5 in VS Code to attach the debugger, and reproduce the bug. The game pauses at the breakpoint. You see the actual values of every local variable, you step through two or three lines, the problem becomes immediately obvious, you fix it. No Debug.Log(). No guessing.

When you commit your changes, the GitLens sidebar shows exactly which lines changed since the last commit, the integrated terminal runs git add and git commit without leaving VS Code, and the Git guide's workflow runs entirely from within the same window you wrote the code in.

Beginner Mistakes

  • Installing VS Code without the .NET SDK and expecting IntelliSense to work. VS Code is a text editor, not a C# IDE. IntelliSense needs the .NET SDK to analyze code. Install the SDK first.
  • Opening VS Code directly instead of through Unity's Assets > Open C# Project. Opening the wrong folder breaks IntelliSense silently. Always open the project root, which Unity's menu option handles automatically.
  • Forgetting to regenerate project files after changing Unity version or adding packages. Unity generates different .csproj files depending on which packages are installed. Adding a new package and not regenerating means VS Code does not know that package's API exists.
  • Leaving OmniSharp enabled after installing C# Dev Kit. The two systems conflict. C# Dev Kit is the correct modern choice; OmniSharp was the predecessor and should be disabled when running C# Dev Kit.
  • Setting breakpoints but forgetting to attach the debugger in VS Code before reproducing the bug. Unity will run past the breakpoint without pausing if VS Code is not attached. Press F5 after pressing Play in Unity, before triggering the code you want to debug.
  • Using VS Code's built-in terminal to run Unity commands. Unity is not a command-line tool in the way Git or Node.js are — it needs to be run through its own editor or through the Unity Hub. Use the VS Code terminal for Git, not for launching Unity.

 

Best Practices

  • Always open your Unity project in VS Code through Assets > Open C# Project, not by directly opening the folder — it saves troubleshooting IntelliSense issues that result from the wrong root folder.
  • Regenerate project files every time you update Unity or install a new package, so VS Code stays aware of the full API surface.
  • Add the .vscode/settings.json file with the search.exclude and file associations settings to source control, so everyone working on the project gets the same VS Code behaviour without individual setup.
  • Use the debugger with breakpoints instead of Debug.Log() for any bug that requires inspecting variable state — it is dramatically faster once you are comfortable attaching it.
  • Keep the C# Dev Kit and Unity extensions updated. Both are actively developed and frequent updates fix IntelliSense issues that can appear between Unity and VS Code version combinations.


Frequently Asked Questions

Is VS Code good for Unity development?

Yes, once it is configured correctly. Out of the box it is just a text editor, but with C# Dev Kit, the Unity extension, and the .NET SDK installed, it provides full IntelliSense, code navigation, and debugging support for Unity C# development.

What is the difference between VS Code and Visual Studio for Unity?

Visual Studio is a full IDE with deeper built-in Unity integration and works correctly with minimal setup. VS Code is a lightweight editor that requires manual configuration but is faster, smaller, and more versatile across different languages and project types. JetBrains Rider sits above both in Unity-specific code analysis but costs money.

Why is IntelliSense not working for Unity classes in VS Code?

The most common causes are a missing .NET SDK, VS Code opened from the wrong folder (not the project root), or Unity's project files not having been regenerated after the external editor preference was changed. The troubleshooting section covers all four causes in order.

Do I need the .NET SDK to use VS Code with Unity?

Yes. VS Code does not include C# language tooling — it needs the .NET SDK installed separately to power IntelliSense, error highlighting, and code analysis for C# files.

What is C# Dev Kit and do I need it?

C# Dev Kit is Microsoft's current recommended VS Code extension for C# development. It replaced the older OmniSharp-based C# extension as the primary option. You need it for IntelliSense, error detection, and code navigation in Unity C# scripts.

Can I debug Unity scripts using VS Code?

Yes. The Unity extension adds a debugger that attaches to a running Unity instance, letting you set breakpoints and inspect variables in your scripts at runtime without needing Visual Studio.

Should I use OmniSharp or C# Dev Kit with Unity in VS Code?

C# Dev Kit is the correct choice in 2026. OmniSharp was the previous system and is no longer actively recommended by Microsoft for new setups. If you have an old OmniSharp configuration, disable it before installing C# Dev Kit to avoid conflicts.

What extensions do I actually need for Unity in VS Code?

The two essential ones are C# Dev Kit (Microsoft) and Unity (Unity Technologies). Everything else is optional. Several older third-party Unity extensions conflict with these and should be disabled.

How do I open a Unity project in VS Code correctly?

In Unity, go to Assets > Open C# Project. This opens VS Code at the correct project root folder with the Unity-generated project files in the right location for IntelliSense to work. Opening VS Code directly from a subfolder or from the desktop frequently breaks IntelliSense.

Why does VS Code search return results from the Library folder?

Unity's Library folder contains gigabytes of generated cache files that VS Code searches by default. Add the search.exclude settings from this guide to your VS Code configuration to exclude Library, Temp, obj, and Logs from all searches.

Is JetBrains Rider better than VS Code for Unity?

For Unity-specific development, Rider has deeper code analysis — it understands Unity serialization rules, identifies common performance mistakes, and provides Unity-specific refactoring suggestions that neither VS Code nor Visual Studio do natively. If budget is not a constraint, Rider is the better tool. For free options, VS Code configured as described in this guide is the practical choice.

Next Topics To Learn

No comments:

Post a Comment

How to Use ElevenLabs for Game Development: AI Voice Acting, NPC Dialogue, and Sound Design

Most indie games ship without voice acting. Not because developers do not want it, but because hiring voice actors is expensive, scheduling ...