I'm writing a 2D game with some fairly complex off-screen logic, with plenty of room for bugs. My usual habit is to write code with a lot of Asserts in it. When an Assert gets hit I drop into the debugger, have a look around, find and fix the bug. Works for me.

Problem is: how to get Unity Asserts to call into the Visual Studio debugger. So far they just seem to get generate a log message in the Editor Console, and then Unity carries right on as if they didn't matter. What use is that?

There is an 'experimental' option in the Unity VS settings, but it doesn't seem to do anything (good or bad). Any suggestions? I can think of a couple of really hackish things to try, but surely there must be a right way?

After further experimentation:

  1. Enabling Assert.raiseExceptions (only) makes Unity grind to a halt (instead of carrying on regardless) but otherwise no change. No trap into VS.
  2. Enabling the experimental Exceptions mode (only) causes Unity to crash with a bug check on the first assert failure.
  3. Doing 1+2 is the same as 1 only.

This is VS 2015 in case it matters.


1 Answer 1


Do you have Assert.raiseExceptions set? If not it won't stop the execution according to the docs. Relevant info copied here:

A failure of an assertion method does not break the control flow of the execution. On a failure, an assertion message is logged (LogType.Assert) and the execution continues. If Assert.raiseExceptions is set to true, an AssertionException is thrown instead of logging a message.

  • \$\begingroup\$ Sorry, I did RTFM and that is not the answer. See edit. No useful effect. \$\endgroup\$
    – david.pfx
    Nov 11, 2016 at 7:40
  • \$\begingroup\$ I saw somewhere that if it was the Unity VS installed with Unity itself, it wasn't working but if you reinstall it manually it may work. I don't think you're the only one with problems though \$\endgroup\$
    – Cobertos
    Nov 11, 2016 at 8:09
  • \$\begingroup\$ thanks, I think you're right. Perhaps in the fullness of time... \$\endgroup\$
    – david.pfx
    Nov 15, 2016 at 23:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .