FromeCoroutine
FromCoroutineValue
FromMicroCoroutine
StartAsCoroutine
FromCoroutine
UniRx特有的方法,将一个协同方法转化到基础流,协同在订阅的时候被执行,流也会被执行;
执行结果
代码示例
public class No07_Coroutine : MonoBehaviour
{
void Start()
{
var coroutineStream = Observable.FromCoroutine(Coroutine);
coroutineStream.Subscribe(Next, Error, Complete);
}
IEnumerator Coroutine(CancellationToken token)
{
yield return null;
Debug.LogFormat("Coroutine");
}
void Next(Unit unit)
{
Debug.LogFormat("协同事件已经完成");
}
void Error(Exception ex)
{
Debug.LogException(ex);
}
void Complete()
{
Debug.