VSCode debugger not attaching to Unity Editor properly

I’ve come back to Unity after months and discovered that VSCode no longer wants to play ball with Unity. The Debugger for Unity extension is installed and up to date, but when running the Unity Editor launch option, the debugger detaches moments after launching. While playing, none of my breakpoints are hit.

I’ve tried fiddling with the settings in Unity, but to no avail. The ones I understand to be applicable are as follows:

  • Build Settings > Build Configuration = Debug
  • Build Settings > Development Build = True
  • Build Settings > Script Debugging = True
  • Preferences > External Tools > External Script Editor = Visual Studio Code
  • Mode = Debug

The Editor Attaching option is missing entirely, so I can’t even enable it.

I’m using Unity version 2020.3.19f1, VSCode 1.61.1, Debugger for Unity v3.0.2, and Windows 10.0.19042

Edit: Added operating system and version

hi,
I have same problem in mac
so, i resolved using running vscode as sudo in terminal
but, it’s not best solution.
I hope I can be of some help.

@JongokLee Your answer about sudo was helpful.

It lead me to head into MacOS System Preferences > Security & Privacy to change the permissions for VS Code. I gave the VS Code application Full Disk Access, and was now able to attach debugging to Unity.

1 Like

I had to run Unity in Admin mode to attach the debugger from VSCode.

Try going to Edit>Preferences and see if these are your settings. Regenerate the project files afterwards, and it should start working.

On Linux (might be the same for Mac), I had to download and install Mono Download - Stable | Mono

I find this helpful as it automatically finds the process info w/o putting an absolute path in your project:

{
    "name": "Unity Editor",
    "type": "unity",
    "path": "${workspaceFolder}/Library/EditorInstance.json",
    "request": "launch",
},

hey. I worked fine.

Try start debug from VSCode menu, and then bug icon’s color changed to blue.,hey. I worked fine.