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

Add EndOfFrame implementation using UnityEngine.Awaitable #496

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public static UniTask NextFrame(PlayerLoopTiming timing, CancellationToken cance
return new UniTask(NextFramePromise.Create(timing, cancellationToken, out var token), token);
}

#if UNITY_2023_1_OR_NEWER
public static async UniTask WaitForEndOfFrame(CancellationToken cancellationToken = default)
Copy link
Contributor Author

@hadashiA hadashiA Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done a easy implementation that uses async.
Should I consider adding Awaitable.ToUniTask()?

📝 But Awaitable is has so few features that converting it to IUniTaskSource could be inefficient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK to use async.

{
await Awaitable.EndOfFrameAsync(cancellationToken);
}
#else
[Obsolete("Use WaitForEndOfFrame(MonoBehaviour) instead or UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate). Equivalent for coroutine's WaitForEndOfFrame requires MonoBehaviour(runner of Coroutine).")]
public static YieldAwaitable WaitForEndOfFrame()
{
Expand All @@ -86,6 +92,7 @@ public static UniTask WaitForEndOfFrame(CancellationToken cancellationToken)
{
return UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate, cancellationToken);
}
#endif

public static UniTask WaitForEndOfFrame(MonoBehaviour coroutineRunner, CancellationToken cancellationToken = default)
{
Expand Down
Loading