mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-21 07:00:12 +00:00
Merge pull request #23 from TamuraKazunori/fix_enumerator_async
Fixed nested IEnumerator does not consumed
This commit is contained in:
@@ -376,6 +376,27 @@ namespace UniRx.AsyncTests
|
|||||||
throw new Exception("MyException");
|
throw new Exception("MyException");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[UnityTest]
|
||||||
|
public IEnumerator NestedEnumerator() => UniTask.ToCoroutine(async () =>
|
||||||
|
{
|
||||||
|
var time = Time.realtimeSinceStartup;
|
||||||
|
|
||||||
|
await ParentCoroutineEnumerator();
|
||||||
|
|
||||||
|
var elapsed = Time.realtimeSinceStartup - time;
|
||||||
|
((int)Math.Round(TimeSpan.FromSeconds(elapsed).TotalSeconds, MidpointRounding.ToEven)).Should().Be(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
IEnumerator ParentCoroutineEnumerator()
|
||||||
|
{
|
||||||
|
yield return ChildCoroutineEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator ChildCoroutineEnumerator()
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(3);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,7 +191,8 @@ namespace UniRx.Async
|
|||||||
}
|
}
|
||||||
else if (current is IEnumerator e3)
|
else if (current is IEnumerator e3)
|
||||||
{
|
{
|
||||||
while (e3.MoveNext())
|
var e4 = ConsumeEnumerator(e3);
|
||||||
|
while (e4.MoveNext())
|
||||||
{
|
{
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user