Cysharp/UniTask

Add UniTask.WaitUntil overload which takes a target to avoid closure allocation

laicasaane opened this issue · 2 comments

For the context of this proposal:
Since UniTask.WaitUntilValueChanged uses IEqualityComparer to detect if the value has changed, its logic is totally different from UniTask.WaitUntil. So I can't just replace WaitUntil with WaitUntilValueChanged.

My use case is:

var component = await UniTask.WaitUntil(gameObject, static x => x.GetComponent<MyComponent>());

// do something to the retrieved component

I think it's a good idea to add (TState, Func) overloads throughout.

I have implemented the suggested UniTask.WaitUntil, the adjacent UniTask.WaitWhile and also the overloading of UniTask.Defer, which I personally use frequently, and submitted a PR.