- Home /
When I place a breakpoint in my code, it crashes Unity Editor
I have a scene that runs fine in the editor . . . well, almost fine; my camera isn't moving the way I thought I had scripted it. So, I would like to debug it. But if I put a breakpoint in the code while it's running, it crashes the Unity Editor. If I put the add the breakpoint before I hit play, the scene just freezes and never starts.
Does anybody know why this might be happening? One of my MonoBehaviours is multi-threaded; is that a problem?
Answer by Bunny83 · May 13, 2011 at 04:18 PM
First, you can't use multithreaded MonoBehaviours. Unity's scripting engine runs on a single thread. You can use threads but you can't call any Unity api from another thread.
I don't debug that much with MonoDevelop (I use Visual Studio for coding). As far as i know it's the normal behaviour that the editor freezes when you break the execution. You have to continue the execution after you're done with debugging. That's how most debuggers work. The debugged application will be interruped at your breakpoint and will freeze until you continue the application.
Thanks, I hadn't realized we couldn't have multithreaded $$anonymous$$onoBehaviours, but when I went back to my code, the other thread doesn't make any Unity api calls . . . so I should be fine, right? Oh, and I'm sorry, what I said before was confusing. Unity is not stopping on my break points. It never gets there because it freezes at the very beginning.
Well, it's very important if you use your own threads to catch ALL exceptions within your thread. If an exception fall-through to Unity (player, editor) it will mostly crash. That's at least what i figured out the hard way ;) I'm not sure if the debugger can handle those extra threads but i guess it should work.
Your answer
Follow this Question
Related Questions
Unity application randomly freezing on occasion 2 Answers
Editing Animations crashes Unity 1 Answer
Multithreading - Freeze on Second Play 6 Answers
In 5.2.1f1 Editor freezes in play mode 3 Answers
Multithreading freezes editor 1 Answer