介绍若干Unity协程实用技巧
基本使用
yield
//type 1
IEnumerator CoroFunc1()
{
yield return null;
}
//type 2 yield return type is limited to string
IEnumerator<string> CoroFunc2()
{
yield return "hello";
}
//type 3 with param
IEnumerator<string> CoroFunc3(string str)
{
yield return "hello" + str;
}
//type 4 return IEnumerable: not necessary.
IEnumberable CoroFunc4(int i)
{
yield return null;
}内置的YieldInstruction
YieldInstruction可返回值的协程
嵌套协程
可处理异常的协程
Last updated