- Home /
Is it possible to query the Unity (3.0) transform tree from a secondary thread?
Hello. I am integrating a camera control algorithm in a Unity project and, for performance reasons, I would like to execute it in a separate thread, or possibly more than one. This would allow me to:
- have the camera control algorithm running in parallel with the rendering, and
- exploit all the computational power from the machine, e.g. 4, 8 cores.
While, the first might be accomplished with coroutines, the second can not (but correct me if I got it wrong). In my understanding the Unity API is not thread-safe, however I only need to read from the transform tree and perform ray-casting, therefore I need no writing on the Unity data structures. Is it safe to do it? In case it is not, is this one a viable solution?
PS: on the features page they mention "Cooperative Multi-Threading", so I might be just missing some information.
Thank you,
Tommaso
Answer by Ashkan_gc · Oct 13, 2010 at 08:40 AM
as i know all classes are not thread safe and you can not call unity apis from any thread other than the main one. you can test it by yourself because what i know is something about 2.x and it might changed in 3.0
Yes, from the advertisement looks like cooperative multi-threading is with threads :) however I can't find any information about it.