Debugging from Threads

Hi all,

I’ve been using threads to handle a lot of data generation in my game. It’s working fine for the most part, but I’m having a couple minor issues.

I know threads aren’t technically supported by Unity, however it is still possible to use them.

Is there any way at all that I can spit out the errors from my threads to debug in Unity? Or alternatively, at least see what the errors are?

Certain parts are crashing out, and whilst I have an idea what it is, I’m having a pain sorting it.

Any input appreciated!

EDIT : More info in case it’s any use.

I’m relatively confident it’s breaking due to one of many lists being altered whilst the thread is running. Problem is, there’s a lot of lists and it’s hard to tell which one is causing the issue.

Attach a debugger, like MonoDevelop? It will break on exception and you will have a clear look at what the error is.

Threads are technically supported by Unity. It’s just that you can’t use most of the Unity API in threads, but you can use Debug.Log.

–Eric

You can also wrap the thread in a try-catch block. Store any errors generated, then throw these again on the main thread.