How to Fix Unity Not Opening Scripts in Visual Studio Code (Step-by-Step Guide)

How to Fix Unity Not Opening Scripts in Visual Studio Code

When working with Unity, you may sometimes face a common issue — double-clicking a C# script doesn’t open it automatically in Visual Studio Code. This usually happens due to incorrect external tool settings, framework mismatches, or missing configuration files.

In this step-by-step guide, we’ll show you exactly how to set Visual Studio Code as your default script editor, configure your Assembly-CSharp-Editor file properly, and enable useful features like Code Lens to improve your Unity workflow.


Step 1: Change the External Tools Settings

Open Unity and go to Edit → Preferences. Under the External Tools section, choose Visual Studio Code as your default script editor.

Step 2: Open the Assembly-CSharp-Editor File

In your Unity project folder, locate and open the file named Assembly-CSharp-Editor. This file defines the framework your scripts use. Ensure that the version listed here matches the one installed on your system.

💡 Tip: Download and install the same .NET Framework version mentioned in this file for full compatibility.

Step 3: Enable Code Lens in Visual Studio Code

Now open Visual Studio Code, go to Settings → Code Lens, and make sure the checkbox is ticked. Code Lens provides inline information about references and methods — making it easier to navigate your Unity scripts.

Final Thoughts

Once you’ve completed these three steps, Unity will automatically open C# scripts in Visual Studio Code without any problems. This setup not only saves time but also helps improve productivity for developers working on complex Unity projects.

Using Visual Studio Code as your primary script editor provides a lightweight, fast, and feature-rich environment — perfect for debugging, linting, and writing cleaner Unity C# code. Combined with features like Code Lens, IntelliSense, and extensions such as “C# for Visual Studio Code,” your development workflow becomes smoother and more efficient.

✅ Other instructions: Unity tutorial

Now you’re ready to build and debug your Unity project seamlessly with Visual Studio Code!