Esempio n. 1
0
    public void Update()
    {
        if (Input.touchCount > 0 && !hasTouched)
        {
            touchStart = Input.touches [0].position;
        }

        if (Input.touchCount > 0 && vm.getTutorialIsShown())
        {
            hasTouched = true;
            lastTouch  = Input.touches [0];
            print("scrollRect: " + _scrollRect.horizontalNormalizedPosition);
        }
        else if (hasTouched && Input.touchCount == 0 && vm.getTutorialIsShown())
        {
            touchEnd = lastTouch.position;
            float deltaX = touchStart.x - touchEnd.x;
            print("deltaX antes: " + deltaX);
            deltaX = deltaX / Screen.width;
            print("deltaX: " + deltaX);

            float hNP = _scrollRect.horizontalNormalizedPosition;

            if (deltaX < -0.2f && currentPage != 0)
            {
                currentPage--;
            }
            else if (deltaX > 0.2f && currentPage != Imagenes.Length - 1)
            {
                currentPage++;
            }

            updatePage(currentPage);
        }
    }