public class WaitForSecondsRealtime : CustomYieldInstruction
{
private float m_WaitUntilTime = -1f;
public float waitTime
{
get;
set;
}
public override bool keepWaiting
{
get
{
bool flag = this.m_WaitUntilTime < 0f;
if (flag)
{
this.m_WaitUntilTime = Time.realtimeSinceStartup + this.waitTime;
}
bool flag2 = Time.realtimeSinceStartup < this.m_WaitUntilTime;
bool flag3 = !flag2;
if (flag3)
{
this.m_WaitUntilTime = -1f;
}
return flag2;
}
}
public WaitForSecondsRealtime(float time)
{
this.waitTime = time;
}
}
从源码里可以看出,在等待时间到达的那一帧,flag2为fales,所以m_WaitUntilTime 被置为了-1,当同一帧再次获取keepWaiting值时,flag2就重新报变为true了。因为update在协程前调用,所以当update里每帧都获取keepWaiting时,协程就无法进行下去。
|