Request: Remove or fix `UniTask.WaitForEndOfFrame`
See original GitHub issueFrom README:
await UniTask.WaitForEndOfFrame() is not equivalent to coroutine’s yield return new WaitForEndOfFrame(). Coroutine’s WaitForEndOfFrame seems to run after the PlayerLoop is done. Some methods that require coroutine’s end of frame(ScreenCapture.CaptureScreenshotAsTexture, CommandBuffer, etc) do not work correctly when replaced with async/await. In these cases, use a coroutine instead.
This caused huge problems for us, as we had assumed that UniTask methods are one-to-one equivalents to Unity’s. Given that Unity’s WaitForEndOfFrame
exists primarily to serve ScreenCapture.CaptureScreenshotAsTexture
etc. it is almost guaranteed to cause confusion. In our case CaptureScreenshotAsTexture
was failing silently on certain platforms, just creating grey textures.
Is it not possible to have a coroutine run in the background that called yield WaitForEndOfFrame()
and then continues the async function containing user code? If not then I suggest this method is deprecated and then either renamed or removed completely.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
I’ve add
UniTask.WaitForEndOfFrame(MonoBehaviour)
, it reuse task and coroutine so more lightweight than standard coroutine. It will release soon.Great solution, thanks @neuecc.