Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class AwaitableUtils
- {
- public static async Awaitable WaitUntil(Func<bool> condition, float timeoutSeconds = float.PositiveInfinity)
- {
- float t = 0f;
- while (!condition())
- {
- if (t >= timeoutSeconds)
- return;
- t += Time.deltaTime;
- await Awaitable.NextFrameAsync();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment