Shenma is a float cloud. in unity, you can write the source code of Coroutine coroutine.
Sun Guangdong 2014.7.19
You can see that an article on the Unity wiki is about writing coroutine by yourself. I think it is very good, so that I can better understand the operating mechanism and other features of the coroutine.
The original Article URL is as follows:
Http://wiki.unity3d.com/index.php? Title = CoroutineScheduler
Project address: http://download.csdn.net/detail/u010019717/8912069
The specific content is as follows:
A simple Collaborative Scheduling program. This collaborative scheduling program allows full control over the execution mechanism of a set of collaborative programs. Reading the Code also helps you understand how collaboration works behind the scenes. Building on how a collaborative program builds a. Net generator will allow you to add collaborative support to a non-Unity project.
Collaborative yield can wait until the next update "yield;", until the specified number of updates has passed "yield anInt;" until the given second has passed "yield aFloat ;", or until another coroutine has completed "yield scheduler. startCoroutine (Coroutine ());". startCoroutine (Coroutine ());".
Multiple scheduling program instances are supported and can be very useful. Collaborative running can run under a different scheduler instance (waiting ).
Do not use the YieldInstruction class of Unity, because we cannot access the internal data of the scheduling required for this class. Semantics is slightly different from the scheduling program of Unity. For example, in Unity, if you start to collaborate with it, it will run immediately for its first yield. However, in the self-written scheduler, it will not run until the next call to UpdateAllCoroutines. This feature allows you to start a coroutine at any time in any code. At the same time, make sure that the coprocessor can only run at a specific time.
The updated order should not be dependent between the same update cooperations.
For more in-depth understanding and learning