Skip to content

WaitUntil with buildin Delay #711

@ModischFabrications

Description

@ModischFabrications

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions