Eonirr

Untitled

May 4th, 2026 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. public static class AwaitableUtils
  2. {
  3. public static async Awaitable WaitUntil(Func<bool> condition, float timeoutSeconds = float.PositiveInfinity)
  4. {
  5. float t = 0f;
  6.  
  7. while (!condition())
  8. {
  9. if (t >= timeoutSeconds)
  10. return;
  11.  
  12. t += Time.deltaTime;
  13. await Awaitable.NextFrameAsync();
  14. }
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment