public IPromise WaitUnscaled(float seconds, Action <float> progressCallback = null) { Deferred deferred = Deferred.GetFromPool(); awaiters.Add(new Awaiter { duration = seconds, finishTime = Time.unscaledTime + seconds, unscaledTime = true, additionalCondition = null, progressCallback = progressCallback, resolver = deferred, }); return(deferred); }
public IPromise WaitForTrue(Func <bool> condition) { Deferred deferred = Deferred.GetFromPool(); awaiters.Add(new Awaiter { duration = 0f, finishTime = Time.unscaledTime, unscaledTime = true, additionalCondition = condition, progressCallback = null, resolver = deferred, }); return(deferred); }
/// <summary> /// adds new promise constructor to current promise and returns wrapper that resolves with added promise /// A.Then(B) - returns promise that resolves when promise from B is resolved /// </summary> /// <param name="next">constructor for next promise</param> /// <returns>Promise</returns> public IPromise Then(Func <IPromise> next) { Deferred deferred = Deferred.GetFromPool(); Done(() => { IPromise promise = next(); promise.Done(() => deferred.Resolve()); promise.Fail(ex => deferred.Reject(ex)); }); Fail(ex => deferred.Reject(ex)); return(deferred); }