Cysharp / Cysharp/UniTask

WaitUntil with buildin Delay

Open
#711 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
11.2k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

I have a few non-reactive properties I need to await to continue my logic that are not time-critical. I would like to trade quick responses for efficiency by skipping a few frames before checking again, but I see no buildin way of doing that.

Simple checks are fine as is, e.g. await UniTask.WaitUntil(() => _readyToRespawn);. Don't actually need it every frame, but it's cheap enough that I don't care.

My problem is more expensive checks. I have resorted to the two-liner below for now, but I think it would be nice to have this kind of delay as a parameter instead. Might also offer some additional performance improvements by relaxing timings internally for UniTask as well?

// cheaper alternative to waitUntil for expensive operation
while (Vector3.Distance(drone.transform.position, transform.position) < safetyDistance)
    await UniTask.Delay(100);

WaitUntilValueChanged might want the same extension, but I couldn't find docs to look into it more.

Feel free to close if this is out of scope.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing UniTask.WaitUntil API and its usage, then compare it with WaitUntilValueChanged and the documented behavior. Define how an optional delay or skipped-frame check should work for expensive predicates, and consider whether both APIs should support it; done means the requested non-every-frame waiting behavior is available and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
game-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.