Beispiel #1
0
        IEnumerator OutAnimationsEnumerator(bool instantAction, bool shouldDisable = true)
        {
            if (UIManager.firstPass)
            {
                //We need this WaitForEndOfFrame so that the UIManager gets after the first frame the UIScreenRect size and position
                yield return(new WaitForEndOfFrame());
            }

            UIAnimator.StopLoopAnimations(GetRectTransform, GetInitialData);

            UIAnimator.DoMoveOut(moveOut, GetRectTransform, GetInitialData, instantAction);
            UIAnimator.DoRotationOut(rotationOut, GetRectTransform, GetInitialData, instantAction);
            UIAnimator.DoScaleOut(scaleOut, GetRectTransform, GetInitialData, instantAction);
            UIAnimator.DoFadeOut(fadeOut, GetRectTransform, GetInitialData, instantAction);

            if (disableWhenHidden)                                                                     //do we have disableWhenHidden available for this UIElement?
            {
                if (shouldDisable)                                                                     //should this ui element get disabled?
                {
                    yield return(outAnimationsDisableBuffer);                                          //default wait time before the disable

                    if (instantAction == false)                                                        //is this an instant animation
                    {
                        outAnimationsDDisableDelay = new WaitForSeconds(GetOutAnimationsFinishTime()); //we get the max wait time
                        yield return(outAnimationsDDisableDelay);                                      //we wait
                    }

                    ToggleCanvasAndGraphicRaycaster(false);
                    gameObject.SetActive(false); //we disable the UIElement gameObject
                }
            }
            else
            {
                if (instantAction == false)                                                        //is this an instant animation
                {
                    outAnimationsDDisableDelay = new WaitForSeconds(GetOutAnimationsFinishTime()); //we get the max wait time
                    yield return(outAnimationsDDisableDelay);                                      //we wait
                }

                ToggleCanvasAndGraphicRaycaster(false);
            }

            outAnimationsCoroutine = null;
        }
        IEnumerator OutAnimationsEnumerator(bool instantAction, bool shouldDisable = true)
        {
            float start = Time.realtimeSinceStartup;

            UIAnimator.StopLoopAnimations(GetRectTransform, GetInitialData);
            UIAnimator.DoMoveOut(moveOut, GetRectTransform, GetInitialData, instantAction);
            UIAnimator.DoRotationOut(rotationOut, GetRectTransform, GetInitialData, instantAction);
            UIAnimator.DoScaleOut(scaleOut, GetRectTransform, GetInitialData, instantAction);
            UIAnimator.DoFadeOut(fadeOut, GetRectTransform, GetInitialData, instantAction);
            if (disableWhenHidden)
            {
                if (shouldDisable)
                {
                    while (Time.realtimeSinceStartup < start + disableTimeBuffer)
                    {
                        yield return(null);
                    }
                    if (instantAction == false)
                    {
                        while (Time.realtimeSinceStartup < start + outAnimationsFinishTime + disableTimeBuffer)
                        {
                            yield return(null);
                        }
                    }
                    ToggleCanvasAndGraphicRaycaster(false);
                    gameObject.SetActive(false);
                }
            }
            else
            {
                if (instantAction == false)
                {
                    while (Time.realtimeSinceStartup < start + outAnimationsFinishTime + disableTimeBuffer)
                    {
                        yield return(null);
                    }
                }
                ToggleCanvasAndGraphicRaycaster(false);
            }
            outAnimationsCoroutine = null;
            yield return(null);
        }