Ejemplo n.º 1
0
        void Update()
        {
            animDeltaTime = Time.realtimeSinceStartup - animStartTime;

            if (state == 1)
            {
                if (animDeltaTime <= animationDuration)
                {
                    if (transitionInType == TransitionType.RippleMask)
                    {
                        tempVector2             = currentRipple.sizeDelta;
                        tempVector2.x           = Anim.Quint.In(0f, rippleSize, animDeltaTime, animationDuration);
                        tempVector2.y           = tempVector2.x;
                        currentRipple.sizeDelta = tempVector2;
                    }
                    else
                    {
                        if (slideIn != SlideDirection.None)
                        {
                            tempVector2   = theRectTransform.anchoredPosition;
                            tempVector2.x = Anim.Quint.Out(slideInDirectionPosition.x, 0f, animDeltaTime, animationDuration);
                            tempVector2.y = Anim.Quint.Out(slideInDirectionPosition.y, 0f, animDeltaTime, animationDuration);
                            theRectTransform.anchoredPosition = tempVector2;
                        }

                        if (scaleIn)
                        {
                            tempVector3   = theRectTransform.localScale;
                            tempVector3.x = Anim.Quint.Out(scaleInStartValue, 1f, animDeltaTime, animationDuration);
                            tempVector3.y = Anim.Quint.Out(scaleInStartValue, 1f, animDeltaTime, animationDuration);
                            theRectTransform.localScale = tempVector3;
                        }

                        if (fadeIn)
                        {
                            theCanvasGroup.alpha = Anim.Quint.Out(fadeInStartValue, 1f, animDeltaTime, animationDuration);
                        }
                    }
                }
                else
                {
                    if (transitionInType == TransitionType.RippleMask)
                    {
                        theRectTransform.SetParent(transform);
                        theRectTransform.position = screenSpacePosition;
                    }
                    else
                    {
                        if (slideIn != SlideDirection.None)
                        {
                            theRectTransform.anchoredPosition = new Vector2(0f, 0f);
                        }

                        if (scaleIn)
                        {
                            theRectTransform.localScale = new Vector3(1f, 1f, 1f);
                        }

                        if (fadeIn)
                        {
                            theCanvasGroup.alpha = 1f;
                        }
                    }

                    if (hideScreen && hideScreen != this)
                    {
                        hideScreen.HideWithoutTransition();
                        hideScreen = null;
                    }

                    state = 0;
                }
            }
            else if (state == 2)
            {
                if (animDeltaTime <= animationDuration)
                {
                    if (transitionInType == TransitionType.RippleMask)
                    {
                        tempVector2             = currentRipple.sizeDelta;
                        tempVector2.x           = Anim.Quint.In(rippleSize, 0f, animDeltaTime, animationDuration);
                        tempVector2.y           = tempVector2.x;
                        currentRipple.sizeDelta = tempVector2;
                    }
                    else
                    {
                        if (slideOut != SlideDirection.None)
                        {
                            tempVector2   = theRectTransform.anchoredPosition;
                            tempVector2.x = Anim.Quint.Out(0f, slideOutDirectionPosition.x, animDeltaTime, animationDuration);
                            tempVector2.y = Anim.Quint.Out(0f, slideOutDirectionPosition.y, animDeltaTime, animationDuration);
                            theRectTransform.anchoredPosition = tempVector2;
                        }

                        if (scaleOut)
                        {
                            tempVector3   = theRectTransform.localScale;
                            tempVector3.x = Anim.Quint.Out(1f, scaleOutEndValue, animDeltaTime, animationDuration);
                            tempVector3.y = Anim.Quint.Out(1f, scaleOutEndValue, animDeltaTime, animationDuration);
                            theRectTransform.localScale = tempVector3;
                        }

                        if (fadeOut)
                        {
                            theCanvasGroup.alpha = Anim.Quint.Out(1f, fadeOutEndValue, animDeltaTime, animationDuration);
                        }
                    }
                }
                else
                {
                    theRectTransform.SetParent(transform);
                    theRectTransform.position = screenSpacePosition;
                    screenSpace.SetActive(false);
                    state = 0;
                }
            }
        }
        public void Update()
        {
            animDeltaTime = Time.realtimeSinceStartup - animStartTime;

            if (state == AnimationState.TransitioningIn)
            {
                if (animDeltaTime <= animationDuration)
                {
                    if (transitionInType == TransitionType.RippleMask)
                    {
                        tempVector2             = currentRipple.sizeDelta;
                        tempVector2.x           = Anim.Quint.In(0f, rippleSize, animDeltaTime, animationDuration);
                        tempVector2.y           = tempVector2.x;
                        currentRipple.sizeDelta = tempVector2;

                        theRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, thisScreenSize.x);
                        theRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, thisScreenSize.y);
                    }
                    else
                    {
                        if (slideIn != SlideDirection.None)
                        {
                            tempVector2   = theRectTransform.anchoredPosition;
                            tempVector2.x = Anim.Quint.Out(slideInDirectionPosition.x, 0f, animDeltaTime, animationDuration);
                            tempVector2.y = Anim.Quint.Out(slideInDirectionPosition.y, 0f, animDeltaTime, animationDuration);
                            theRectTransform.anchoredPosition = tempVector2;
                        }

                        if (scaleIn)
                        {
                            tempVector3   = theRectTransform.localScale;
                            tempVector3.x = Anim.Quint.Out(scaleInStartValue, 1f, animDeltaTime, animationDuration);
                            tempVector3.y = Anim.Quint.Out(scaleInStartValue, 1f, animDeltaTime, animationDuration);
                            theRectTransform.localScale = tempVector3;
                        }

                        if (fadeIn)
                        {
                            theCanvasGroup.alpha = Anim.Quint.Out(fadeInStartValue, 1f, animDeltaTime, animationDuration);
                        }
                    }
                }
                else
                {
                    if (transitionInType == TransitionType.RippleMask)
                    {
                        theRectTransform.SetParent(transform);
                        theRectTransform.position = screenSpacePosition;

                        theRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, thisScreenSize.x);
                        theRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, thisScreenSize.y);
                    }
                    else
                    {
                        if (slideIn != SlideDirection.None)
                        {
                            theRectTransform.anchoredPosition = new Vector2(0f, 0f);
                        }

                        if (scaleIn)
                        {
                            theRectTransform.localScale = new Vector3(1f, 1f, 1f);
                        }

                        if (fadeIn)
                        {
                            theCanvasGroup.alpha = 1f;
                        }
                    }

                    if (hideScreen && hideScreen != this)
                    {
                        hideScreen.HideWithoutTransition();
                        hideScreen = null;
                    }

                    state = AnimationState.Stationary;
                    if (TransitionInComplete != null)
                    {
                        TransitionInComplete(this, new EventArgs());
                    }
                }
            }
            else if (state == AnimationState.TransitioningOut)
            {
                if (animDeltaTime <= animationDuration)
                {
                    if (transitionInType == TransitionType.RippleMask)
                    {
                        tempVector2             = currentRipple.sizeDelta;
                        tempVector2.x           = Anim.Quint.In(rippleSize, 0f, animDeltaTime, animationDuration);
                        tempVector2.y           = tempVector2.x;
                        currentRipple.sizeDelta = tempVector2;

                        theRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, thisScreenSize.x);
                        theRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, thisScreenSize.y);
                    }
                    else
                    {
                        if (slideOut != SlideDirection.None)
                        {
                            tempVector2   = theRectTransform.anchoredPosition;
                            tempVector2.x = Anim.Quint.Out(0f, slideOutDirectionPosition.x, animDeltaTime, animationDuration);
                            tempVector2.y = Anim.Quint.Out(0f, slideOutDirectionPosition.y, animDeltaTime, animationDuration);
                            theRectTransform.anchoredPosition = tempVector2;
                        }

                        if (scaleOut)
                        {
                            tempVector3   = theRectTransform.localScale;
                            tempVector3.x = Anim.Quint.Out(1f, scaleOutEndValue, animDeltaTime, animationDuration);
                            tempVector3.y = Anim.Quint.Out(1f, scaleOutEndValue, animDeltaTime, animationDuration);
                            theRectTransform.localScale = tempVector3;
                        }

                        if (fadeOut)
                        {
                            theCanvasGroup.alpha = Anim.Quint.Out(1f, fadeOutEndValue, animDeltaTime, animationDuration);
                        }
                    }
                }
                else
                {
                    currentRipple.gameObject.SetActive(false);
                    theRectTransform.SetParent(transform);
                    theRectTransform.position = screenSpacePosition;
                    screenSpace.SetActive(false);
                    state = AnimationState.Stationary;
                }
            }
        }