Пример #1
0
        void Update()
        {
            m_AnimDeltaTime = Time.realtimeSinceStartup - m_AnimStartTime;

            if (m_State == 1)
            {
                if (m_AnimDeltaTime < m_AnimSpeed)
                {
                    m_TempVec2               = m_RectTransform.position;
                    m_TempVec2.y             = Tween.CubeOut(m_CurrentPosition, m_OnPos.y, m_AnimDeltaTime, m_AnimSpeed);
                    m_RectTransform.position = m_TempVec2;
                    m_CanvasGroup.alpha      = Tween.CubeInOut(m_CanvasGroup.alpha, 1f, m_AnimDeltaTime, m_AnimSpeed);
                    if (m_MoveFab)
                    {
                        m_FabRectTransform.position = new Vector3(m_FabRectTransform.position.x, m_FabStartPos + (m_RectTransform.position.y - m_OffPos.y), m_FabRectTransform.position.z);
                    }
                }
                else
                {
                    m_RectTransform.position = m_OnPos;
                    if (m_MoveFab)
                    {
                        m_FabRectTransform.position = new Vector3(m_FabRectTransform.position.x, m_FabStartPos + (m_RectTransform.position.y - m_OffPos.y), m_FabRectTransform.position.z);
                    }
                    StartCoroutine(WaitTime());
                    m_State = 0;
                }
            }
            else if (m_State == 2)
            {
                if (m_AnimDeltaTime < m_AnimSpeed)
                {
                    m_TempVec2               = m_RectTransform.position;
                    m_TempVec2.y             = Tween.CubeInOut(m_CurrentPosition, m_OffPos.y, m_AnimDeltaTime, m_AnimSpeed);
                    m_RectTransform.position = m_TempVec2;
                    m_CanvasGroup.alpha      = Tween.CubeIn(m_CanvasGroup.alpha, m_OffAlpha, m_AnimDeltaTime, m_AnimSpeed);
                    if (m_MoveFab)
                    {
                        m_FabRectTransform.position = new Vector3(m_FabRectTransform.position.x, m_FabStartPos + (m_RectTransform.position.y - m_OffPos.y), m_FabRectTransform.position.z);
                    }
                }
                else
                {
                    if (m_MoveFab)
                    {
                        m_FabRectTransform.position = new Vector3(m_FabRectTransform.position.x, m_FabStartPos, m_FabRectTransform.position.z);
                    }
                    m_State = 0;
                    OnAnimDone();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// See Monobehaviour.Update.
        /// </summary>
        private void Update()
        {
            if (!highlightGraphic)
            {
                m_AnimState = 0;
                return;
            }

            if (m_AnimState == 1)
            {
                m_AnimDeltaTime = Time.realtimeSinceStartup - m_AnimStartTime;

                if (m_AnimDeltaTime <= m_AnimDuration)
                {
                    highlightGraphic.color = Tween.CubeOut(m_CurrentColor, highlightColor, m_AnimDeltaTime, m_AnimDuration);
                    CheckTransparency();
                }
                else
                {
                    highlightGraphic.color = highlightColor;
                    CheckTransparency();

                    m_AnimState = 0;
                }
            }
            else if (m_AnimState == 2)
            {
                m_AnimDeltaTime = Time.realtimeSinceStartup - m_AnimStartTime;

                if (m_AnimDeltaTime <= m_AnimDuration)
                {
                    highlightGraphic.color = Tween.CubeOut(m_CurrentColor, m_NormalColor.a < 0.015f ? m_HighlightColor.WithAlpha(0f) : m_NormalColor, m_AnimDeltaTime, m_AnimDuration);
                    CheckTransparency();
                }
                else
                {
                    highlightGraphic.color = m_NormalColor;
                    CheckTransparency();

                    m_AnimState = 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);
                }
            }
        }
        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;
                }
            }
        }