示例#1
0
        public void Initialize(float duration, float delay, Tween.TweenType tweenType, Action callback, AnimationCurve animationCurve, bool scaledTime, int id)
        {
            m_Duration = duration;
            m_Delay = delay;
            m_TweenType = tweenType;
            m_Callback = callback;
            m_CustomCurve = animationCurve;
            m_ScaledTime = scaledTime;
            m_TweenId = id;

            if (m_Delay > 0)
            {
                m_WaitingForDelay = true;
            }
            else
            {
                m_WaitingForDelay = false;
                StartTween();
            }

            m_Active = true;
        }
示例#2
0
        private void UpdateAnimBar()
        {
            if (rectTransform == null)
            {
                return;
            }
            if (m_AnimBar == 0)
            {
                return;
            }

            float deltaTime = Time.realtimeSinceStartup - m_AnimBarStartTime;

            m_BarLength = rectTransform.GetProperSize().x;

            if (m_AnimBar == 1)
            {
                if (deltaTime < animDuration)
                {
                    Vector2 tempVector2 = m_BarRectTransform.sizeDelta;
                    tempVector2.x = Tween.CubeIn(m_AnimBarCurrentSize, m_BarLength / 2f, deltaTime, animDuration);
                    m_BarRectTransform.sizeDelta = tempVector2;

                    tempVector2   = m_BarRectTransform.anchoredPosition;
                    tempVector2.x = Tween.CubeIn(m_AnimBarCurrentPos, m_BarLength / 4f, deltaTime, animDuration);
                    m_BarRectTransform.anchoredPosition = tempVector2;
                }
                else
                {
                    Vector2 tempVector2 = m_BarRectTransform.sizeDelta;
                    tempVector2.x = m_BarLength / 2f;
                    m_BarRectTransform.sizeDelta = tempVector2;

                    tempVector2   = m_BarRectTransform.anchoredPosition;
                    tempVector2.x = m_BarLength / 4f;
                    m_BarRectTransform.anchoredPosition = tempVector2;

                    m_AnimBarCurrentSize = m_BarRectTransform.sizeDelta.x;
                    m_AnimBarCurrentPos  = m_BarRectTransform.anchoredPosition.x;
                    m_AnimBarStartTime   = Time.realtimeSinceStartup;
                    m_AnimBar            = 2;
                }
                return;
            }
            if (m_AnimBar == 2)
            {
                if (deltaTime < animDuration)
                {
                    Vector2 tempVector2 = m_BarRectTransform.sizeDelta;
                    tempVector2.x = Tween.CubeOut(m_AnimBarCurrentSize, 0f, deltaTime, animDuration);
                    m_BarRectTransform.sizeDelta = tempVector2;

                    tempVector2   = m_BarRectTransform.anchoredPosition;
                    tempVector2.x = Tween.CubeOut(m_AnimBarCurrentPos, m_BarLength, deltaTime, animDuration);
                    m_BarRectTransform.anchoredPosition = tempVector2;
                }
                else
                {
                    Vector2 tempVector2 = m_BarRectTransform.sizeDelta;
                    tempVector2.x = 0f;
                    m_BarRectTransform.sizeDelta = tempVector2;

                    tempVector2   = m_BarRectTransform.anchoredPosition;
                    tempVector2.x = 0f;
                    m_BarRectTransform.anchoredPosition = tempVector2;

                    m_AnimBarCurrentSize = m_BarRectTransform.sizeDelta.x;
                    m_AnimBarCurrentPos  = m_BarRectTransform.anchoredPosition.x;
                    m_AnimBarStartTime   = Time.realtimeSinceStartup;
                    m_AnimBar            = 1;
                }
                return;
            }
            if (m_AnimBar == 3)
            {
                if (deltaTime < animDuration && Application.isPlaying)
                {
                    Vector2 tempVector2 = m_BarRectTransform.sizeDelta;
                    tempVector2.x = Tween.CubeInOut(m_AnimBarCurrentSize, m_AnimBarTargetSize, deltaTime, animDuration);
                    m_BarRectTransform.sizeDelta = tempVector2;

                    tempVector2   = m_BarRectTransform.anchoredPosition;
                    tempVector2.x = Tween.CubeInOut(m_AnimBarCurrentPos, 0f, deltaTime, animDuration);
                    m_BarRectTransform.anchoredPosition = tempVector2;
                }
                else
                {
                    Vector2 tempVector2 = m_BarRectTransform.sizeDelta;
                    tempVector2.x = m_AnimBarTargetSize;
                    m_BarRectTransform.sizeDelta = tempVector2;

                    tempVector2   = m_BarRectTransform.anchoredPosition;
                    tempVector2.x = 0f;
                    m_BarRectTransform.anchoredPosition = tempVector2;

                    m_AnimBar = 0;
                }
            }
        }
示例#3
0
        /// <summary>
        /// See MonoBehaviour.Update.
        /// </summary>
        void Update()
        {
            m_ScrollPosition = m_ScrollRect.normalizedPosition;

            #region EdgeDetection

            if (m_ScrollPosition.x == 0f)
            {
                if (m_LastScrollPosition.x != 0f)
                {
                    OnEdgeHit(0);
                }
            }
            else if (m_ScrollPosition.x == 1f)
            {
                if (m_LastScrollPosition.x != 1f)
                {
                    OnEdgeHit(1);
                }
            }
            else
            {
                if (m_LastScrollPosition.x == 1f || m_LastScrollPosition.x == 0f)
                {
                    OnEdgeStray(true);
                }
            }

            if (m_ScrollPosition.y == 0f)
            {
                if (m_LastScrollPosition.y != 0f)
                {
                    OnEdgeHit(3);
                }
            }
            else if (m_ScrollPosition.y == 1f)
            {
                if (m_LastScrollPosition.y != 1f)
                {
                    OnEdgeHit(2);
                }
            }
            else
            {
                if (m_LastScrollPosition.y == 1f || m_LastScrollPosition.y == 0f)
                {
                    OnEdgeStray(false);
                }
            }

            #endregion

            #region MouseDetection

            if (Input.GetMouseButtonUp(0))
            {
                if (m_PointerCount >= 1)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if ((m_ScrollHorizontal && i <= 1) || (m_ScrollVertical && i >= 2))
                        {
                            float tempPosition   = (i <= 1) ? m_ScrollPosition.x : m_ScrollPosition.y;
                            float targetPosition = (i == 0 || i == 3) ? 0f : 1f;

                            if (m_PointerDown[i] && tempPosition == targetPosition)
                            {
                                m_EdgeAnimsCurrent[i]   = m_OverscrollAmounts[i];
                                m_EdgeAnimsPower[i]     = 0;
                                m_EdgeAnimsStartTime[i] = Time.realtimeSinceStartup;
                                m_EdgeAnims[i]          = 3;
                            }
                        }
                    }

                    for (int i = 0; i < m_PointerDown.Length; i++)
                    {
                        m_PointerDown[i] = false;
                    }
                }
                else
                {
                    for (int i = 0; i < 4; i++)
                    {
                        m_PointerDown[i] = false;
                    }

                    m_PointerCount = 1;
                }

                m_PointerCount--;
            }

            #endregion

            #region MouseMovement

            bool[] anims = new bool[4];

            for (int i = 0; i < 4; i++)
            {
                if ((m_ScrollHorizontal && i <= 1) || (m_ScrollVertical && i >= 2))
                {
                    float tempPosition   = (i <= 1) ? m_ScrollPosition.x : m_ScrollPosition.y;
                    float targetPosition = (i == 0 || i == 3) ? 0f : 1f;

                    if (m_PointerDown[i] && tempPosition == targetPosition)
                    {
                        float fingerOffset        = (i <= 1) ? Input.mousePosition.y - m_RectTransform.position.y : Input.mousePosition.x - m_RectTransform.position.x;
                        float tempSize            = (i <= 1) ? m_Size.y : m_Size.x;
                        float tempMouseDifference = (i <= 1) ? (Input.mousePosition.x - m_PointerDownPosition.x) / Screen.width : (Input.mousePosition.y - m_PointerDownPosition.y) / Screen.height;

                        fingerOffset = (fingerOffset >= 0f) ? Tween.Linear(0, tempSize / 4f, fingerOffset, tempSize / 2f) : -Tween.Linear(0, tempSize / 4f, -fingerOffset, tempSize / 2f);

                        m_OverscrollPositions[i] = Mathf.Lerp(m_OverscrollPositions[i], fingerOffset, Time.deltaTime * 10f);

                        if (i == 1 || i == 2)
                        {
                            tempMouseDifference *= -1;
                        }


                        m_OverscrollAmounts[i] = Mathf.Lerp(m_PointerBaseAmounts[i], tempSize / 4f, tempMouseDifference);

                        anims[i] = false;
                    }
                    else
                    {
                        anims[i] = true;
                    }
                }
            }

            #endregion

            #region Animations

            for (int i = 0; i < m_OverscrollRectTransforms.Length; i++)
            {
                if (anims[i])
                {
                    if (m_EdgeAnims[i] == 1)
                    {
                        m_EdgeAnimsDeltaTime[i] = Time.realtimeSinceStartup - m_EdgeAnimsStartTime[i];

                        if (m_EdgeAnimsDeltaTime[i] < m_EdgeAnimDuration)
                        {
                            m_OverscrollAmounts[i] = Tween.CubeOut(m_EdgeAnimsCurrent[i], m_EdgeAnimsPower[i], m_EdgeAnimsDeltaTime[i], m_EdgeAnimDuration);
                        }
                        else
                        {
                            float tempPosition   = (i <= 1) ? m_ScrollPosition.x : m_ScrollPosition.y;
                            float targetPosition = (i == 0 || i == 3) ? 0f : 1f;

                            if (tempPosition == targetPosition)
                            {
                                m_EdgeAnimsCurrent[i]   = m_OverscrollAmounts[i];
                                m_EdgeAnimsPower[i]     = 0;
                                m_EdgeAnimsStartTime[i] = Time.realtimeSinceStartup;
                                m_EdgeAnims[i]          = 2;
                            }
                            else
                            {
                                m_OverscrollAmounts[i] = m_EdgeAnimsPower[i];
                                m_EdgeAnims[i]         = 0;
                            }
                        }
                    }
                    else if (m_EdgeAnims[i] == 2)
                    {
                        m_EdgeAnimsDeltaTime[i] = Time.realtimeSinceStartup - m_EdgeAnimsStartTime[i];

                        if (m_EdgeAnimsDeltaTime[i] < m_EdgeAnimDuration)
                        {
                            m_OverscrollAmounts[i] = Tween.CubeIn(m_EdgeAnimsCurrent[i], m_EdgeAnimsPower[i], m_EdgeAnimsDeltaTime[i], m_EdgeAnimDuration);
                        }
                        else
                        {
                            m_OverscrollAmounts[i] = m_EdgeAnimsPower[i];
                            m_EdgeAnims[i]         = 0;
                        }
                    }
                    else if (m_EdgeAnims[i] == 3)
                    {
                        m_EdgeAnimsDeltaTime[i] = Time.realtimeSinceStartup - m_EdgeAnimsStartTime[i];

                        if (m_EdgeAnimsDeltaTime[i] < m_EdgeAnimDuration * 2f)
                        {
                            m_OverscrollAmounts[i] = Tween.CubeIn(m_EdgeAnimsCurrent[i], m_EdgeAnimsPower[i], m_EdgeAnimsDeltaTime[i], m_EdgeAnimDuration * 2f);
                        }
                        else
                        {
                            m_OverscrollAmounts[i] = m_EdgeAnimsPower[i];
                            m_EdgeAnims[i]         = 0;
                        }
                    }

                    m_OverscrollPositions[i] = Mathf.Lerp(m_OverscrollPositions[i], 0f, Time.deltaTime);
                }
            }

            #endregion

            for (int i = 0; i < m_OverscrollRectTransforms.Length; i++)
            {
                if ((m_ScrollHorizontal && i <= 1) || (m_ScrollVertical && i >= 2))
                {
                    Vector2 tempAnchoredPos = (i <= 1) ? new Vector2(0f, m_OverscrollPositions[i]) : new Vector2(m_OverscrollPositions[i], 0f);
                    float   tempSize        = (i <= 1) ? m_Size.y : m_Size.x;

                    m_OverscrollRectTransforms[i].anchoredPosition = tempAnchoredPos;
                    m_OverscrollRectTransforms[i].sizeDelta        = new Vector2(tempSize * 1.5f, m_OverscrollAmounts[i] * m_OverscrollScale);
                    m_LastScrollPosition        = m_ScrollPosition;
                    m_OverscrollImages[i].color = m_OverscrollColor.WithAlpha((m_OverscrollAmounts[i] / (tempSize / 4f)) * m_OverscrollColor.a);
                }
            }
        }
示例#4
0
        /// <summary>
        /// See MonoBehaviour.Update.
        /// </summary>
        void Update()
        {
            m_AnimDeltaTime = Time.realtimeSinceStartup - m_AnimStartTime;

            if (m_State == 1)
            {
                if (m_AnimDeltaTime <= m_AnimationDuration)
                {
                    canvasGroup.alpha = Tween.QuintOut(m_CurrentAlpha, rippleData.EndAlpha, m_AnimDeltaTime, m_AnimationDuration);
                    float size = Tween.QuintOut(m_CurrentSize, CalculateSize(), m_AnimDeltaTime, m_AnimationDuration);
                    rectTransform.sizeDelta = new Vector2(size, size);
                    SubmitSizeForSoftening();

                    if (rippleData.MoveTowardCenter)
                    {
                        Vector3 parentPosition = m_RippleParent.GetPositionRegardlessOfPivot();
                        rectTransform.position = Tween.QuintOut(m_CurrentPosition, new Vector3(parentPosition.x, parentPosition.y, m_RippleParent.position.z), m_AnimDeltaTime, m_AnimationDuration);
                    }
                }
                else
                {
                    if (m_Oscillate)
                    {
                        m_State         = 3;
                        m_AnimStartTime = Time.realtimeSinceStartup;
                        m_CurrentSize   = rectTransform.rect.width;
                        m_CurrentSize  *= 0.95f;
                    }
                    else
                    {
                        m_State = 0;
                    }
                }
            }
            else if (m_State == 2)
            {
                if (m_AnimDeltaTime <= m_AnimationDuration * 2f)
                {
                    canvasGroup.alpha = Tween.QuintOut(m_CurrentAlpha, 0f, m_AnimDeltaTime, m_AnimationDuration * 2f);
                    float size = Tween.QuintOut(m_CurrentSize, CalculateSize(), m_AnimDeltaTime, m_AnimationDuration);
                    rectTransform.sizeDelta = new Vector2(size, size);
                    SubmitSizeForSoftening();

                    if (rippleData.MoveTowardCenter)
                    {
                        Vector3 parentPosition = m_RippleParent.GetPositionRegardlessOfPivot();
                        rectTransform.position = Tween.QuintOut(m_CurrentPosition, new Vector3(parentPosition.x, parentPosition.y, m_RippleParent.position.z), m_AnimDeltaTime, m_AnimationDuration);
                    }
                }
                else
                {
                    m_State = 0;
                    if (m_RippleCreator != null)
                    {
                        m_RippleCreator.OnDestroyRipple();
                    }
                    RippleManager.instance.ReleaseRipple(this);
                }
            }
            else if (m_State == 3)
            {
                float size = Tween.Sin(m_CurrentSize, m_CurrentSize * 0.05f, m_AnimDeltaTime * 4);

                rectTransform.sizeDelta = new Vector2(size, size);
                SubmitSizeForSoftening();
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_DisableWhenNotVisible, true);

            bool hasScreen = m_MaterialScreen.screenView != null;

            if (hasScreen)
            {
                EditorGUILayout.PropertyField(m_OptionsControlledByScreenView, true);
            }
            else
            {
                EditorGUILayout.HelpBox("Please place on a ScreenView", MessageType.Warning);
            }

            if (!m_MaterialScreen.optionsControlledByScreenView && hasScreen)
            {
                bool fadeIn    = m_FadeIn.boolValue;
                bool scaleIn   = m_ScaleIn.boolValue;
                bool slideIn   = m_SlideIn.boolValue;
                bool rippleIn  = m_RippleIn.boolValue;
                bool fadeOut   = m_FadeOut.boolValue;
                bool scaleOut  = m_ScaleOut.boolValue;
                bool slideOut  = m_SlideOut.boolValue;
                bool rippleOut = m_RippleOut.boolValue;

                if (fadeIn)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_FadeIn);
                        EditorGUILayout.PropertyField(m_FadeInTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_FadeInTweenType.enumValueIndex == 0)
                        {
                            m_MaterialScreen.fadeInCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_MaterialScreen.fadeInCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_FadeInAlpha,
                                                      new GUIContent("Initial Alpha"));
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_FadeIn);
                }

                if (scaleIn)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_ScaleIn);
                        EditorGUILayout.PropertyField(m_ScaleInTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_ScaleInTweenType.enumValueIndex == 0)
                        {
                            m_MaterialScreen.scaleInCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_MaterialScreen.scaleInCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_ScaleInScale,
                                                      new GUIContent("Initial Scale"));
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_ScaleIn);
                }

                if (slideIn)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_SlideIn);
                        EditorGUILayout.PropertyField(m_SlideInTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_SlideInTweenType.enumValueIndex == 0)
                        {
                            m_MaterialScreen.slideInCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_MaterialScreen.slideInCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_SlideInDirection,
                                                      new GUIContent("From the"));
                        EditorGUILayout.PropertyField(m_AutoSlideInAmount,
                                                      new GUIContent("Auto distance"));
                        if (m_AutoSlideInAmount.boolValue)
                        {
                            EditorGUILayout.PropertyField(m_SlideInPercent,
                                                          new GUIContent("Auto distance percent"));
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(m_SlideInAmount,
                                                          new GUIContent("Distance"));
                        }
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_SlideIn);
                }

                if (rippleIn)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_RippleIn);
                        EditorGUILayout.PropertyField(m_RippleInTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_RippleInTweenType.enumValueIndex == 0)
                        {
                            m_MaterialScreen.rippleInCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_MaterialScreen.rippleInCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_RippleInType,
                                                      new GUIContent("Position type"));
                        if (m_RippleInType.enumValueIndex == 1)
                        {
                            EditorGUILayout.PropertyField(m_RippleInPosition,
                                                          new GUIContent("Position"));
                        }
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_RippleIn);
                }

                EditorGUILayout.Space();

                if (fadeOut)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_FadeOut);
                        EditorGUILayout.PropertyField(m_FadeOutTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_FadeOutTweenType.enumValueIndex == 0)
                        {
                            m_MaterialScreen.fadeOutCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_MaterialScreen.fadeOutCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_FadeOutAlpha,
                                                      new GUIContent("Initial Alpha"));
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_FadeOut);
                }

                if (scaleOut)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_ScaleOut);
                        EditorGUILayout.PropertyField(m_ScaleOutTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_ScaleOutTweenType.enumValueIndex == 0)
                        {
                            m_MaterialScreen.scaleOutCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_MaterialScreen.scaleOutCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_ScaleOutScale,
                                                      new GUIContent("Initial Scale"));
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_ScaleOut);
                }

                if (slideOut)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_SlideOut);
                        EditorGUILayout.PropertyField(m_SlideOutTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_SlideOutTweenType.enumValueIndex == 0)
                        {
                            m_MaterialScreen.slideOutCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_MaterialScreen.slideOutCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_SlideOutDirection,
                                                      new GUIContent("From the"));
                        EditorGUILayout.PropertyField(m_AutoSlideOutAmount,
                                                      new GUIContent("Auto distance"));
                        if (m_AutoSlideOutAmount.boolValue)
                        {
                            EditorGUILayout.PropertyField(m_SlideOutPercent,
                                                          new GUIContent("Auto distance percent"));
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(m_SlideOutAmount,
                                                          new GUIContent("Distance"));
                        }
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_SlideOut);
                }

                if (rippleOut)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_RippleOut);
                        EditorGUILayout.PropertyField(m_RippleOutTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_RippleOutTweenType.enumValueIndex == 0)
                        {
                            m_MaterialScreen.rippleOutCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_MaterialScreen.rippleOutCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_RippleOutType,
                                                      new GUIContent("Position type"));
                        if (m_RippleOutType.enumValueIndex == 1)
                        {
                            EditorGUILayout.PropertyField(m_RippleOutPosition,
                                                          new GUIContent("Position"));
                        }
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_RippleOut);
                }

                EditorGUILayout.PropertyField(m_TransitionDuration);
            }

            serializedObject.ApplyModifiedProperties();
        }
示例#6
0
        private void UpdateAnimCircle()
        {
            if (circleImage == null)
            {
                return;
            }
            if (m_AnimCircle == 0)
            {
                return;
            }

            if (m_AnimCircle == 1)
            {
                float animDeltaTime = Time.realtimeSinceStartup - m_AnimCircleStartTime;

                if (animDeltaTime < animDuration)
                {
                    circleImage.fillAmount = Tween.CubeInOut(m_AnimCircleCurrentFillAmount, 0.75f, animDeltaTime,
                                                             animDuration);
                }
                else
                {
                    m_AnimCircleCurrentFillAmount = 0.75f;
                    circleImage.fillAmount        = 0.75f;
                    FlipCircle(false);
                    m_AnimCircleStartTime = Time.realtimeSinceStartup;
                    m_AnimCircle          = 2;
                }

                m_CircleRectTransform.localEulerAngles = new Vector3(m_CircleRectTransform.localEulerAngles.x,
                                                                     m_CircleRectTransform.localEulerAngles.y,
                                                                     m_CircleRectTransform.localEulerAngles.z - Time.unscaledDeltaTime * 200f);
                return;
            }

            if (m_AnimCircle == 2)
            {
                float animDeltaTime = Time.realtimeSinceStartup - m_AnimCircleStartTime;

                if (animDeltaTime < animDuration)
                {
                    circleImage.fillAmount = Tween.CubeInOut(m_AnimCircleCurrentFillAmount, 0.1f, animDeltaTime,
                                                             animDuration);
                }
                else
                {
                    m_AnimCircleCurrentFillAmount = 0.1f;
                    circleImage.fillAmount        = 0.1f;
                    FlipCircle(true);
                    m_AnimCircleStartTime = Time.realtimeSinceStartup;
                    m_AnimCircle          = 1;
                }

                m_CircleRectTransform.localEulerAngles = new Vector3(m_CircleRectTransform.localEulerAngles.x,
                                                                     m_CircleRectTransform.localEulerAngles.y,
                                                                     m_CircleRectTransform.localEulerAngles.z - Time.unscaledDeltaTime * 200f);
                return;
            }

            if (m_AnimCircle == 3)
            {
                float animDeltaTime = Time.realtimeSinceStartup - m_AnimCircleStartTime;

                if (animDeltaTime < animDuration)
                {
                    circleImage.fillAmount = Tween.CubeInOut(m_AnimCircleCurrentFillAmount, m_CurrentProgress, animDeltaTime,
                                                             animDuration);
                    Vector3 tempVector3 = m_CircleRectTransform.localEulerAngles;
                    tempVector3.z = Tween.CubeInOut(m_AnimCircleCurrentRotation, 0f, animDeltaTime, animDuration);
                    m_CircleRectTransform.localEulerAngles = tempVector3;
                }
                else
                {
                    m_AnimCircleCurrentFillAmount = circleImage.fillAmount = m_CurrentProgress;
                    Vector3 tempVector3 = m_CircleRectTransform.localEulerAngles;
                    tempVector3.z = 0f;
                    m_CircleRectTransform.localEulerAngles = tempVector3;
                    m_AnimCircleStartTime = Time.realtimeSinceStartup;
                    m_AnimCircle          = 0;
                }
            }
        }
示例#7
0
        void Update()
        {
            if (m_IsTransitioning > 0)
            {
                m_TransitionDeltaTime = Time.realtimeSinceStartup - m_TransitionStartTime;

                if (m_TransitionDeltaTime <= transitionDuration)
                {
                    if (m_IsTransitioning == 1)
                    {
                        if (rippleIn)
                        {
                            Vector3 tempVector3 = m_Ripple.position;
                            tempVector3.x     = Tween.Evaluate(rippleInTweenType, m_CurrentRipplePos.x, m_TargetRipplePos.x, m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            tempVector3.y     = Tween.Evaluate(rippleInTweenType, m_CurrentRipplePos.y, m_TargetRipplePos.y, m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            tempVector3.z     = Tween.Evaluate(rippleInTweenType, m_CurrentRipplePos.z, m_TargetRipplePos.z, m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            m_Ripple.position = tempVector3;

                            Vector2 tempVector2 = m_Ripple.sizeDelta;
                            tempVector2.x      = Tween.Evaluate(rippleInTweenType, 0, m_TempRippleSize.x, m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            tempVector2.y      = Tween.Evaluate(rippleInTweenType, 0, m_TempRippleSize.y, m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            m_Ripple.sizeDelta = tempVector2;

                            rectTransform.position = m_TempScreenPos;

                            rectTransform.localScale = new Vector3(m_TempRippleScale.x / ripple.localScale.x, m_TempRippleScale.y / ripple.localScale.y, m_TempRippleScale.z / ripple.localScale.z);
                        }
                        if (fadeIn)
                        {
                            canvasGroup.alpha = Tween.Evaluate(fadeInTweenType, fadeInAlpha, 1f, m_TransitionDeltaTime,
                                                               transitionDuration, fadeInCustomCurve);
                        }
                        if (scaleIn)
                        {
                            Vector3 tempVector3 = rectTransform.localScale;
                            tempVector3.x = Tween.Evaluate(scaleInTweenType, scaleInScale, 1f, m_TransitionDeltaTime,
                                                           transitionDuration, scaleInCustomCurve);
                            tempVector3.y            = tempVector3.x;
                            tempVector3.z            = tempVector3.x;
                            rectTransform.localScale = tempVector3;
                        }
                        if (slideIn)
                        {
                            Vector3 tempVector3 = rectTransform.position;
                            tempVector3.x = Tween.Evaluate(slideInTweenType, m_SlideScreenPos.x, m_TempScreenPos.x, m_TransitionDeltaTime,
                                                           transitionDuration, slideInCustomCurve);
                            tempVector3.y = Tween.Evaluate(slideInTweenType, m_SlideScreenPos.y, m_TempScreenPos.y, m_TransitionDeltaTime,
                                                           transitionDuration, slideInCustomCurve);
                            rectTransform.position = tempVector3;
                        }
                    }
                    else if (m_IsTransitioning == 2)
                    {
                        if (rippleOut)
                        {
                            Vector3 tempVector3 = m_Ripple.position;
                            tempVector3.x     = Tween.Evaluate(rippleInTweenType, m_CurrentRipplePos.x, m_TargetRipplePos.x, m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            tempVector3.y     = Tween.Evaluate(rippleInTweenType, m_CurrentRipplePos.y, m_TargetRipplePos.y, m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            tempVector3.z     = Tween.Evaluate(rippleInTweenType, m_CurrentRipplePos.z, m_TargetRipplePos.z, m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            m_Ripple.position = tempVector3;

                            Vector2 tempVector2 = m_Ripple.sizeDelta;
                            tempVector2.x = Tween.Evaluate(rippleInTweenType, m_TempRippleSize.x, 0,
                                                           m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            tempVector2.y = Tween.Evaluate(rippleInTweenType, m_TempRippleSize.y, 0,
                                                           m_TransitionDeltaTime, m_TransitionDuration, rippleInCustomCurve);
                            m_Ripple.sizeDelta = tempVector2;

                            rectTransform.position = m_TempScreenPos;

                            rectTransform.localScale = new Vector3(m_TempRippleScale.x / ripple.localScale.x, m_TempRippleScale.y / ripple.localScale.y, m_TempRippleScale.z / ripple.localScale.z);
                        }
                        if (fadeOut)
                        {
                            canvasGroup.alpha = Tween.Evaluate(fadeOutTweenType, 1f, fadeOutAlpha,
                                                               m_TransitionDeltaTime, transitionDuration, fadeOutCustomCurve);
                        }
                        if (scaleOut)
                        {
                            Vector3 tempVector3 = rectTransform.localScale;
                            tempVector3.x = Tween.Evaluate(scaleOutTweenType, 1f, scaleOutScale, m_TransitionDeltaTime,
                                                           transitionDuration, scaleOutCustomCurve);
                            tempVector3.y            = tempVector3.x;
                            tempVector3.z            = tempVector3.x;
                            rectTransform.localScale = tempVector3;
                        }
                        if (slideOut)
                        {
                            Vector3 tempVector3 = rectTransform.position;
                            tempVector3.x = Tween.Evaluate(slideOutTweenType, m_TempScreenPos.x, m_SlideScreenPos.x,
                                                           m_TransitionDeltaTime, transitionDuration, slideOutCustomCurve);
                            tempVector3.y = Tween.Evaluate(slideOutTweenType, m_TempScreenPos.y, m_SlideScreenPos.y, m_TransitionDeltaTime,
                                                           transitionDuration, slideOutCustomCurve);
                            rectTransform.position = tempVector3;
                        }
                    }
                }
                else
                {
                    if (m_IsTransitioning == 1)
                    {
                        if (rippleIn)
                        {
                            rectTransform.SetParent(screenView.transform, true);
                            rectTransform.position         = m_TempScreenPos;
                            rectTransform.anchorMin        = Vector2.zero;
                            rectTransform.anchorMax        = Vector2.one;
                            rectTransform.sizeDelta        = Vector2.zero;
                            rectTransform.anchoredPosition = Vector2.zero;
                            rectTransform.localScale       = m_TempRippleScale;
                            ripple.gameObject.SetActive(false);
                        }
                        if (fadeIn)
                        {
                            canvasGroup.alpha = 1f;
                        }
                        if (scaleIn)
                        {
                            rectTransform.localScale = new Vector3(1f, 1f, 1f);
                        }
                        if (slideIn)
                        {
                            rectTransform.position = m_TempScreenPos;
                        }
                    }
                    else if (m_IsTransitioning == 2)
                    {
                        if (rippleOut)
                        {
                            rectTransform.SetParent(screenView.transform, true);
                            rectTransform.position         = m_TempScreenPos;
                            rectTransform.anchorMin        = Vector2.zero;
                            rectTransform.anchorMax        = Vector2.one;
                            rectTransform.sizeDelta        = Vector2.zero;
                            rectTransform.anchoredPosition = Vector2.zero;
                            rectTransform.localScale       = m_TempRippleScale;
                            ripple.gameObject.SetActive(false);
                        }
                        if (fadeOut)
                        {
                            canvasGroup.alpha = 1f;
                        }
                        if (scaleOut)
                        {
                            rectTransform.localScale = new Vector3(1f, 1f, 1f);
                        }
                        if (slideOut)
                        {
                            rectTransform.position = m_TempScreenPos;
                        }
                    }

                    if (m_IsTransitioning > 1)
                    {
                        if (m_DisableWhenNotVisible)
                        {
                            gameObject.SetActive(false);
                        }
                    }

                    m_IsTransitioning = 0;
                    screenView.OnScreenEndTransition(screenIndex);
                }
            }
        }
示例#8
0
        public void Initialize(Action<Color> updateValue, Func<Color> startValue, Func<Color> targetValue, float duration, float delay, Tween.TweenType tweenType, Action callback, AnimationCurve animationCurve, bool scaledTime, int id)
        {
            m_GetStartValue = startValue;
            m_UpdateValue = updateValue;
            m_GetTargetValue = targetValue;

            base.Initialize(duration, delay, tweenType, callback, animationCurve, scaledTime, id);
        }
示例#9
0
        public DialogAnimatorSlide(float animationDuration, SlideDirection slideInDirection, SlideDirection slideOutDirection, Tween.TweenType slideInTweenType, Tween.TweenType slideOutTweenType)
        {
            m_AnimationDuration = animationDuration;
            m_SlideInDirection = slideInDirection;
            m_SlideOutDirection = slideOutDirection;

            if (slideInTweenType == Tween.TweenType.Custom || slideOutTweenType == Tween.TweenType.Custom)
            {
                Debug.LogWarning("Cannot set tween type to 'Custom'");
            }
            else
            {
                m_SlideInTweenType = slideInTweenType;
                m_SlideOutTweenType = slideOutTweenType;
            }
        }