Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support awaiting additional engine callbacks #554

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nandos13
Copy link

@nandos13 nandos13 commented Mar 16, 2024

Pull request adds the ability for a task to await the invocation of some additional Unity callbacks:

  • Application.onBeforeRender via method UniTask.WaitForOnBeforeRender
  • Canvas.willRenderCanvases via method UniTask.WaitForWillRenderCanvases
  • Canvas.preWillRenderCanvases via method UniTask.WaitForPreWillRenderCanvases

Implementation notes:

  • Additional enum EngineCallbackTiming defines these callbacks (similar to PlayerLoopTiming) with the InjectEngineCallbackTimings counterpart. - I figured it was best to keep these separated since they do not use the PlayerLoop.
  • Core continuation-running logic was split out of PlayerLoopRunner into new base class ContinuationRunner so it could be shared with new class EngineCallbackRunner for these callbacks.
  • The callback WaitFor methods utilize YieldPromise which was changed to accommodate the new enum with minimal changes.

Add EngineCallbackTiming enumeration with support for Application.onBeforeRender, Canvas.willRenderCanvases & Canvas.preWillRenderCanvases callbacks.
Extract PlayerLoopRunner core logic into new base class ContinuationRunner.
Add new EngineCallbackRunner class for running callbacks supported by EngineCallbackTiming enum.
Modify YieldPromise to support creating a promise for the new enum.
Canvas.preWillRenderCanvases callback is available in 2020.3.0 and later
@neuecc
Copy link
Member

neuecc commented Mar 28, 2024

It doesn't seem like an appropriate scenario to make it awaitable with UniTask.
Are there any special use cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants