目录
NextFrame
下一帧
void Start()
{
Debug.Log(Time.frameCount);
StartCoroutine(NextFrame(() => Debug.Log(Time.frameCount)));
Observable.NextFrame()
.Subscribe(_ => Debug.LogFormat("Observable NextFrame:{0}", Time.frameCount));
}
IEnumerator NextFrame(Action callback)
{
yield return new WaitForEndOfFrame();
callback();
}
DelayFrame
延迟帧数
Debug.Log(Time.frameCount);
Observable.ReturnUnit()
.Do(_ => Debug.Log(Time.frameCount))
.DelayFrame(10)
.Do(_ => Debug.Log(Time.frameCount))
.Subscribe(_ => Debug.Log(Time.frameCount));
FrameInterval
计算/累计/计时 帧数
Observable.EveryUpdate()
.Where(_ => Input.GetMouseButtonDown(0))
.Timestamp()
.TimeInterval()
.FrameInterval()
.Subscribe(frameInterval => Debug.LogFormat("距离上一次点击的帧数:{0},时间间隔:{1}", frameInterval.Interval,
f