When you are used to the power of Visual Studio, debugging Unity can be awkward and frustrating. The common approach is to set debug messages in code, cross your fingers and hope when the game runs you set the message in the correct place for it to be useful. This approach was fine in the ’80s when I had more patience, but now it is just painful.
I heard of SyntaxTree’s UnityVS from some more experienced Unity developers but they were put off by the price: ~$100 for an individual license. They were not the only ones.
Hmmm… the price did not sound to bad if UnityVS does what it says in the list of features. The features I am interested in are Seamless Integration, Debugging, and the Unity Console within Visual Studio.
I had some time and with the free 14 day free trial, I decided to give UnityVS a test run.
Installation of UnityVS 2012
The UnityVS 14 day trial is given out per email address, and given a password supplied by email, the download (~7mb) and installation process was straightforward .
Sample Project
At the same time, I decided to take a look at the Unity 4.3 2D support by downloading the sample project from the Asset Store.
After downloading the package, I created a new project and selected the following packages:
First off, I opened the Level scene and gave the game a run. Cool, my little character runs around the screen as expected.
I then found an interesting looking script attached to the hero and double clicked. Visual Studio, my default script editor, launched and I am presented with a dialog to enter my UnityVS license that I received attached to my registration email:
As expected, Visual Studio correctly shows the scripts in the project; granted the display is more clear. I like the Seamless Integration feature but still not worth $100.
Unity debug message
Let’s say we wanted to identify when the number of available bombs goes from 1 to 0. A simple way would be to add the highlighted debug message in the LayBombs.cs script:
Now when the game is run and the player runs out of bombs, the following is printed to the Unity console window:
Now with UnityVS
Let’s check out UnityVS now. The first thing is to check the integration while the game is running in Unity. I simply start the debugger in Visual Studio (F5). UnityVS gives me a prompt at the bottom to let me know it is all ready:
And after some game play, yes the console is log messages are shown in the Error List window with the benefit of extra information. Nice feature!
Now, let’s get rid of the code to write the debug message and set a breakpoint when the number of bombs is decremented.
Now when the breakpoint is triggered when a bomb is laid, and as expected, a view of the variables in scope are available:
It is important to note that gameplay stops while the breakpoint is active.
Why Visual Studio?
For those that might not be familiar with Visual Studio, there are many cool features. Just to illustrate one, I decided to change the breakpoint to only fire when the number of bombs becomes 0. To do this simply set a condition to the breakpoint by selecting the condition option on the breakpoint:
and entering in the following evaluation:
Now the breakpoint will only trigger when the bombs run out. The great thing here is your code does not become clouded with pointless debug messages.
Definitely worth the price.