当前位置:网站首页>Synergetic process

Synergetic process

2022-06-23 12:39:00 First wife ash yuanai

The teacher defined : Start another logical processing while the main thread is running , To assist in the execution of current procedures .

The official definition of : Xiecheng is a branch executive , Encounter conditions (yield return sentence ) Will hang up , Until the condition is met, it will be waked up and continue to execute the following code .

Points of attention :

1.Unity At every frame (Frame) Will deal with the coroutines on the object .Unity Mainly in the Update Post processing process ( Check whether the conditions of the cooperation process are met ), But there are also exceptions :

2. Synergetic process Update() It's the same , All are Unity The function that each frame pair will handle ( If any ). If MonoBehaviour Is active (active) State and yield Satisfy the condition of ,

Will execute the following code of the coroutine method . You can also find : If you call a coroutine in the early stage of an object , The collaboration will run immediately to the first yield return Statement place , If it is yield return null , Will be awakened again at the same frame .

3.Unity Of C# The return value of a coroutine in the code is usually IEnumerator( iterator ) type ,IEnumerator There are two ways to interface , Namely Current and MoveNext. We can simply think that :

A coroutine is a function that returns an iterator , At first the iterator's Current Point to the beginning of the function , Every time MoveNext,Current Point to the next yield return The value returned . The iterator method runs to yield return

When the sentence is , Will return a expression Expression and keep the current position in the code . The next time the iterator function is called, execution restarts from that location .

Unity What you do at each frame is : call coroutines ( iterator )MoveNext() Method , If you return true , Just continue from the current position .
 

原网站

版权声明
本文为[First wife ash yuanai]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231202149515.html