Attaching Visual Studio debugger to Unity

Daniel Kirwan
2 min readSep 9, 2024

--

You can easily attach the Visual Studio debugger for when you want to debug your game by simple using the attach to Unity button in Visual Studio. Now, You will need to open the solution or any of your projects C# files in Visual Studio first from the Unity Editor.

Onec you click this, Visual Studio will run through some connections in the background to connect to Unity. Now, go back to the Unity Editor and you should be greated with a pop-up that asks you if you would like to enable debugging for this session. Click Enable debugging for this session.

And thats it, you can now start to debug your game using Visual Studio. Just add a break point into your code, go back to Unity and start playing the game. When the game hits the point in the code where your breakpoint is, you will be able to see the state of your variables and track down those pesky bugs. I won’t be going through any debugging tips today, so good luck with your debugging.

One more thing that you can do, is enable debugging for your project so that you do not have to enable it every time inside of Unity once attaching via Visual studio.

In the bottom right corner of the Unity Editor, there is a tiny little bug image. Click the bug image and you can enable debugging for your project.

Click switch to debug mode. This is what Visual studio is doing when you click the attach button. And that’s it. Now, all you have to do is click attach inside of Visual Studio and it will attach. You no longer need to confirm in Unity.

--

--