Exemple #1
0
    public IEnumerator scrollRoutine(bool up = true)
    {
        scrolling = true;
        bool scrollable = true;

        float time = 0.0f;

        while (time < 0.5f)
        {
            if (up)
            {
                if (transform.position.y < highPos.y - 100 && upPossible)
                {
                    scrollable = false;
                    break;
                }
            }
            else
            {
                if (transform.position.y > lowPos.y + 100 && downPossible)
                {
                    scrollable = false;
                    break;
                }
            }
            yield return(null);

            time += Time.deltaTime;
        }
        if (up && scrollable)
        {
            scroll.moveObjects(gameObject, -1);
            yield return(StartCoroutine(scroll.scrollRoutine(0.2f, false, gameObject)));

            calculateAnchors();
            updateState();
        }
        else if (scrollable)
        {
            scroll.moveObjects(gameObject, 1);
            yield return(StartCoroutine(scroll.scrollRoutine(0.2f, true, gameObject)));

            calculateAnchors();
            updateState();
        }

        StartCoroutine(EndDrag());
        scrolling = false;
    }