UniRx操作符补充

LuLuEarl / 2023-08-20 / 原文

1.NextFrame

 

public class NextFrameSample : MonoBehaviour
{
    private void Start()
    {
        Application.targetFrameRate = 1;

        Observable.NextFrame(FrameCountType.EndOfFrame)
            .Subscribe(_ =>
            {
                Debug.Log("Start:"+Time.frameCount);
            });
    }

    private void Update()
    {
        Debug.Log( Time.frameCount);
        if (Input.GetKeyDown(KeyCode.Space))
        {
            //下一帧的Updata执行
            Observable.NextFrame()
                .Subscribe(_ =>
                {
                    Debug.Log("Update"+Time.frameCount);
                });
           //下一帧的FixedUpdate执行
            Observable.NextFrame(FrameCountType.FixedUpdate)
                .Subscribe(_ =>
                {
                    Debug.Log("FixedUpdate"+Time.frameCount);
                });
           //下一帧结束执行
            Observable.NextFrame(FrameCountType.EndOfFrame)
                .Subscribe(_ =>
                {
                    Debug.Log("EndOfFrame"+Time.frameCount);
                });
                
        }
    }
}

  

2.DelayFrame

 

3.FrameInterval

 

4.BatchFrame

 

5.ForEachAsync

 

6.FrameTimeInterval

 

7.SampleFrame

 

8.RepeatUntilDestroy

 

9.ObserveOnMainThread

 

10.DelayFrameSubscript

 

11.ThrottleFirstFrame

 

12.ThrottleFrame

 

13.TimeoutFrame

 

14.TakeUntilDestroy

 

15.TakeUntilDisable

 

16.RepeatUntilDisable