- Home /
How to Manage System Intensive Tasks
Hi I wanted to know how to manage system intensive tasks that freeze the game up when they are done. Can I run them parallel to the rest of the game of the rest of the game does not require them immediately? Or do I have to create some sort of load screen?
Also if I make the task a co routine if the co routine calls a function that's not itself a co routine will that be executed in the normal thread?
Answer by whydoidoit · Mar 26, 2013 at 06:57 PM
Coroutines are specifically not threads - they do run on the normal main thread so if they take time, the game will freeze - it doesn't matter what they call. I wrote examples and explanations of both Coroutines and Threads on Unity Gems.
You could write a coroutine that yielded frequently, and it can call anything. But you are in control so you'd have to space out the process by inserting yields. This can make it slower if you do too many, or the game will still freeze if you do too few.
Thanks, The problem was building waypoint connections. I have played around with yield lengths and found that if I build a way points connections every 0.15s and for each way point i calculate ones connected to it very 0.02 seconds i suffer virtually no performance hit.
Yeah it's a balancing act. Nice to do it on a thread if you can - but there's no way of doing that if you have to raycast etc.
Unfortunately I only connect way points that are in each others LOS don't want them linking through walls :)
Yeah I have to do the same thing - still once connected you can path find on another thread :)
Your answer
Follow this Question
Related Questions
Return value from coroutine to non monobehaviour 1 Answer
Coroutine not starting 1 Answer
Alternative for semaphores in Unity? 2 Answers
Saving data question 1 Answer
NetworkStream.GetStream() Coroutine 1 Answer