private static IPromise WaitForRequest <T>(AsyncOperationHandle <T> request, string message)
    {
        var p = Promise.Create();

        CoroutineExtensions.WaitUntil(() => request.IsDone)
        .ThenDo(() => {
            if (!request.IsValid())     // request was auto-collected
            {
                Debug.Log(message);
                p.Resolve();
                return;
            }

            if (request.Status == AsyncOperationStatus.Succeeded)
            {
                Debug.Log(message);
                p.Resolve(request.Result);
            }
            else if (request.Status == AsyncOperationStatus.Failed)
            {
                Debug.LogException(request.OperationException);
                p.Reject(request.OperationException);
            }
        });

        return(p);
    }
Example #2
0
 public static IPromise WaitForEndOfState(this Animator animator, int layer = 0)
 {
     return(CoroutineExtensions.WaitUntil(() =>
                                          animator.GetCurrentAnimatorStateInfo(layer).normalizedTime >= 0.999f));
 }
Example #3
0
 public static IPromise WaitUntilState(this Animator animator, string state, int layer = 0)
 {
     return(CoroutineExtensions.WaitUntil(() => animator.GetCurrentAnimatorStateInfo(layer).IsName(state)));
 }
Example #4
0
 public static IPromise WaitUntilState(this Animator animator, int state, int layer = 0)
 {
     return(CoroutineExtensions.WaitUntil(() => animator.GetCurrentAnimatorStateInfo(layer).shortNameHash == state));
 }