Example #1
0
    private IEnumerator MoveSortButtons(int _position)
    {
        m_ButtonsMoving = true;
        float   target;
        Vector3 leftScrollTarget, rightScrollTarget, rightAnchTarget, leftAnchTarget;

        if (_position == 0)             //Move inwards
        {
            target            = 2.21f;
            leftScrollTarget  = new Vector3(m_LeftScrollPosx + target, m_LeftScroll.transform.localPosition.y, m_LeftScroll.transform.localPosition.z);
            rightScrollTarget = new Vector3(m_RightScrollPosx - target, m_RightScroll.transform.localPosition.y, m_RightScroll.transform.localPosition.z);
            rightAnchTarget   = new Vector3(0.0f - target, m_RightButtonAnchor.transform.localPosition.y, m_RightButtonAnchor.transform.localPosition.z);
            leftAnchTarget    = new Vector3(0.0f + target, m_RightButtonAnchor.transform.localPosition.y, m_RightButtonAnchor.transform.localPosition.z);

            if (m_LeftScroll.gameObject.activeSelf)
            {
                m_LeftScroll.SetAlpha(0.46875f);
                m_RightScroll.SetAlpha(0.46875f);

                StartCoroutine(m_LeftScroll.AlphaFade(0.0f, 0.02f));
                StartCoroutine(m_RightScroll.AlphaFade(0.0f, 0.02f));
            }
            if (m_TopScroll.gameObject.activeSelf)
            {
                m_TopScroll.SetAlpha(0.46875f);
                m_BotScroll.SetAlpha(0.46875f);

                StartCoroutine(m_TopScroll.AlphaFade(0.0f, 0.02f));
                StartCoroutine(m_BotScroll.AlphaFade(0.0f, 0.02f));
            }
        }
        else if (_position == 1)            //Move outwards
        {
            leftScrollTarget  = new Vector3(m_LeftScrollPosx, m_LeftScroll.transform.localPosition.y, m_LeftScroll.transform.localPosition.z);
            rightScrollTarget = new Vector3(m_RightScrollPosx, m_RightScroll.transform.localPosition.y, m_RightScroll.transform.localPosition.z);
            rightAnchTarget   = new Vector3(0.0f, m_RightButtonAnchor.transform.localPosition.y, m_RightButtonAnchor.transform.localPosition.z);
            leftAnchTarget    = new Vector3(0.0f, m_RightButtonAnchor.transform.localPosition.y, m_RightButtonAnchor.transform.localPosition.z);

            if (!m_LeftScroll.gameObject.activeSelf)
            {
                EnableHorizontalTriggers(true);

                m_LeftScroll.SetAlpha(0.0f);
                m_RightScroll.SetAlpha(0.0f);

                StartCoroutine(m_LeftScroll.AlphaFade(0.46875f, 0.02f));
                StartCoroutine(m_RightScroll.AlphaFade(0.46875f, 0.02f));
            }

            if (!m_TopScroll.gameObject.activeSelf)
            {
                EnableVerticalTriggers(true);

                m_TopScroll.SetAlpha(0.0f);
                m_BotScroll.SetAlpha(0.0f);

                StartCoroutine(m_TopScroll.AlphaFade(0.46875f, 0.01f));
                StartCoroutine(m_BotScroll.AlphaFade(0.46875f, 0.01f));
            }
        }
        else           //Half move for when vertical scrolling is not needed.
        {
            target            = 1.2f;
            leftScrollTarget  = new Vector3(m_LeftScrollPosx + target - 0.13f, m_LeftScroll.transform.localPosition.y, m_LeftScroll.transform.localPosition.z);
            rightScrollTarget = new Vector3(m_RightScrollPosx - target + 0.13f, m_RightScroll.transform.localPosition.y, m_RightScroll.transform.localPosition.z);
            rightAnchTarget   = new Vector3(0.0f - target, m_RightButtonAnchor.transform.localPosition.y, m_RightButtonAnchor.transform.localPosition.z);
            leftAnchTarget    = new Vector3(0.0f + target, m_RightButtonAnchor.transform.localPosition.y, m_RightButtonAnchor.transform.localPosition.z);

            if (!m_LeftScroll.gameObject.activeSelf)
            {
                EnableHorizontalTriggers(true);

                m_LeftScroll.SetAlpha(0.0f);
                m_RightScroll.SetAlpha(0.0f);

                StartCoroutine(m_LeftScroll.AlphaFade(0.46875f, 0.02f));
                StartCoroutine(m_RightScroll.AlphaFade(0.46875f, 0.02f));
            }
        }

        float time = 2.0f * Time.deltaTime;

        while (Vector3.Distance(m_RightButtonAnchor.transform.localPosition, rightAnchTarget) > 0.05f)
        {
            m_RightScroll.transform.localPosition       = Vector3.Lerp(m_RightScroll.transform.localPosition, rightScrollTarget, time);
            m_LeftScroll.transform.localPosition        = Vector3.Lerp(m_LeftScroll.transform.localPosition, leftScrollTarget, time);
            m_RightButtonAnchor.transform.localPosition = Vector3.Lerp(m_RightButtonAnchor.transform.localPosition, rightAnchTarget, time);
            m_LeftButtonAnchor.transform.localPosition  = Vector3.Lerp(m_LeftButtonAnchor.transform.localPosition, leftAnchTarget, time);
            yield return(null);
        }
        m_LeftScroll.transform.localPosition        = leftScrollTarget;
        m_RightScroll.transform.localPosition       = rightScrollTarget;
        m_RightButtonAnchor.transform.localPosition = rightAnchTarget;
        m_LeftButtonAnchor.transform.localPosition  = leftAnchTarget;
        m_ButtonsMoving = false;
    }