VSCode Unity Debugging in 2023
New Unity Debugger for Visual Studio Code: Say Goodbye to Frustration! (2023)
New, unofficial plugin for Visual Studio Code, based on Visual Studio Tools for Unity, brings back the working debugger for Unity Developers.
Debugging is a critical aspect of software development that helps developers identify and fix issues in their code. For Unity game developers, the Debugger for Unity for Visual Studio Code has been an essential tool for debugging their code. However, the official Unity Technologies plugin has almost stopped working, especially in the newest Unity versions, leaving developers high and dry, despite having 1,600,000 installations.
VSCode is a lightweight and popular IDE used by a lot of people worldwide. It’s no surprise that the Stack Overflow 2022 Developer Survey, VSCode as the #1 ranking IDE, used by 74.48% of respondents. However, Unity withdrew its support for VSCode debugging, leaving developers to use other options such as Visual Studio Community, which is heavy and much worse than VSCode, or JetBrains Rider, which is paid and looks like an old Java editing tool (it’s just my opinion 😃). Moreover, there is no Visual Studio Community for Linux, limiting the options for developers who prefer Linux.
Unity’s documentation still mentions that it is possible to debug with VSCode. However, the VSCode page doesn’t mention that yet. This issue has led to frustration among many developers.
Long awaited solution!
Fortunately, there is now a working solution— the Unofficial VSTU Unity Debugger plugin for VSCode made by peposso (github link), based on the official Visual Studio Tools for Unity (VSTU).
Installing the plugin is straightforward. You can find it in VSCode extensions marketplace window:
After installing a plugin, you have to create a launch.json
config file. The easiest way to do so is by automatically generating it here:
Then, choose VSTU Unity Debugger:
After that you should have your config ready.
If you’re a Unity developer who have one generated previously, just add manually VSTU config to your configurations array:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
//
// your other configs here
//
//
// new VSTU config below:
//
{
"name": "Unity Editor (VSTU)",
"type": "vstu-unity",
"request": "attach",
"projectPath": "${workspaceFolder}"
}
//
// end of VSTU config
//
]
}
The, you need to install .NET 7.0 SDK and Visual Studio Tools for Unity if you don’t have them already. Probably, VSCode will show you a prompt with link to do that.
After that, finally, you can Attach to Unity with a press of a button:
The plugin currently supports several basic functionalities, like:
- Function Breakpoints
- Expression Conditional Breakpoints
- Hit Count Conditional Breakpoints
- ‘{hitCount}’ or ‘{operator} {hitCount}’
- Available Operators: =, >, >=, %
- Jump execution point to Cursor.
The plugin author, peposso, did an excellent job of making debugging available for a ton of people, surpassing the Unity and Microsoft (Visual Studio) teams’ efforts. Thanks for that! 👏
In conclusion, the vscode-vstu-debugger plugin for VSCode is an excellent tool for Unity developers who want to debug their code with ease. I’ve tested it myself, and it works like a charm. No more issues with connecting to Unity, no more need to restart Unity, and no more debugger disconnecting on navigating through code or on adding more breakpoints while already breakpointed. Thanks to peposso, we can finally get back to debugging our Unity code with confidence.
External links: