Coroutines 协程
本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.3版本
参考链接:https://docs.unity3d.com/Manual/Coroutines.html
When you call a function, it runs to completion before returning. This effectively means that any action taking place in a function must happen within a single frame update; a function call can’t be used to contain a procedural animation or a sequence of events over time. As an example, consider the task of gradually reducing an object’s alpha (opacity) value until it becomes completely invisible.
当您调用一个函数时,它会在返回之前运行到完成。这实际上意味着在函数中发生的任何操作都必须在单个帧更新中发生;函数调用不能用于包含过程动画或随时间变化的事件序列。例如,考虑逐渐减少对象的alpha(不透明度)值,直到它完全不可见的任务。
void Fade()
{
for (float f = 1f; f