x


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?

more ▼

asked May 13 '11 at 03:55 PM

burns gravatar image

burns
122 8 9 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

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.

more ▼

answered May 13 '11 at 04:18 PM

Bunny83 gravatar image

Bunny83
45.3k 11 49 207

Thanks, I hadn't realized we couldn't have multithreaded MonoBehaviours, 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.

May 13 '11 at 05:11 PM burns

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.

May 13 '11 at 06:00 PM Bunny83
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1673
x591
x177
x45
x25

asked: May 13 '11 at 03:55 PM

Seen: 1317 times

Last Updated: May 13 '11 at 03:55 PM