Unity 105: Debugging and Analyzing

indiesaudi

Abdullah Hamed

Posted on December 10, 2020

Unity 105: Debugging and Analyzing

Visual Studio IDE supports debugging Unity projects. On windows you can add Unity support from the Visual Studio installer by modifying your installation. Unity support is built-in into Visual Studio for Mac, and you do not need to modify your installation.

unity support in Visual Studio installer for windows

Debugging

Debugging enables you to freeze the execution of your script as any point you set using breakpoints. To set a break point, select the area in the margin of Visual Studio IDE next to the line you want the code to freeze at. A red dot should appear on that margin showing that a breakpoint has been set.

a breakpoint with a red dot showing in the margin of visual studio

To start the debugger, you need to have both Visual Studio IDE and Unity running. Select the Attach to Unity button at the top of the Visual Studio IDE.

Attach to Unity button in Visual Studio

If you were using Unity 2020 and up, Unity might ask you to enable debugging. Select Enable for this session or for all projects.

Enable debugging dialogue in Unity 2020 and up

Visual Studio Unity debugger should start and be ready and attached to Unity.
Unity debugger activated in Visual Studio

Now, select the play button in Unity to run your game. One Unity reaches the line of your code, Unity will freeze. You will be able now to look at the debugger locals window and see properties of your code and game objects. You can hover on variables to see their value at that specific state, or you can dig deeper into the locals window at the bottom of the debugger to see them in a list.

Visual Studio IDE with stopping at a Breakpoint

Please check our full video covering this topic in our video beginner series for Unity.

💖 💪 🙅 🚩
indiesaudi
Abdullah Hamed

Posted on December 10, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Unity 105: Debugging and Analyzing
csharp Unity 105: Debugging and Analyzing

December 10, 2020

Unity 106: Platforms and Builds
csharp Unity 106: Platforms and Builds

December 14, 2020

Unity 104: Physics and Collisions
csharp Unity 104: Physics and Collisions

December 2, 2020

Unity 103: Input
csharp Unity 103: Input

November 23, 2020

Unity 102: Scripting
csharp Unity 102: Scripting

November 19, 2020