How can I find an infinite loop in a very big project in Unity?

I tried to use breakpoints in MonoDevelop and debug, but I was not able to track the loop. I tried to put Debug.Log() in a few places and it did not help as well.

So, are there are any other ways of doing it?

It is possible that the loop is not a problem, but I think it is very unlikely. The problem is that when I perform some actions the Unity Editor just stucks and becomes unresponsive at all and I should disable it through the task manager.

  • \$\begingroup\$ Do you have any editor scripts in Editor folder? That might be causing the problem. \$\endgroup\$ – Umair M Dec 10 '17 at 15:05
  • \$\begingroup\$ What do you mean by find an infinite loop? \$\endgroup\$ – user100681 Dec 10 '17 at 15:05

There's a paid ($15) asset called Panic Button that can help you track this down.

You import it into your project, then run. Once Unity locks up in an infinite loop, hit Shift+Esc to break out of it and get a stack trace of exactly where execution was stuck. This also resumes editing without crashing, so you don't lose unsaved work.

I don't have any affiliation with the creator, but I can confirm it performs as advertised and doesn't introduce undesirable side-effects into the project. For the price of the coffee I'd have burned through tracking down a few of these issues, I'd personally say it's worthwhile. ;)

  • \$\begingroup\$ Holy moly, I want this asset now! Hmm, gotta make a free version of it... \$\endgroup\$ – John Hamilton Dec 12 '17 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.