workaround for parallelizing function calls from Unity API?

Hi there,

I am doing a visual recognition system, and to do more advanced stuff I need to use a lot of raycasts, however that won’t do it in term of performance if they have to be done sequentially. On the other hand, it looks like it is not possible to parallelize function calls from the Unity API, is it really completely the case or can I do some kind of configuration to allow that?

Thank you in advance for your help,

Minsc

If you need actual parallelism you can use threading, but all access to the Unity API must happen on the main thread.

Another common technique for heavy workloads is to spread the work across multiple frames - Coroutines are good for doing this. If you’re not doing a lot of raycasts all the time this may be a viable option.