protected void UpdateButtons()
    {
        if (backwardButton != null)
        {
            if (_firstIndex >= 0)
            {
                _firstItemPos = scrollView.draggablePanel.movement == UIScrollView.Movement.Horizontal ?
                                UICamera.mainCamera.WorldToScreenPoint(_widgets[_firstIndex].transform.position).x :
                                UICamera.mainCamera.WorldToScreenPoint(_widgets[_firstIndex].transform.position).y;

                backwardButton.isEnabled = scrollView.draggablePanel.movement == UIScrollView.Movement.Horizontal ?
                                           _firstItemPos <_backwardPos + scrollView.spacing * 0.1f :
                                                          _firstItemPos> _backwardPos - scrollView.spacing * 0.1f;

                if (!backwardButton.isEnabled && backScroll)
                {
                    backScroll = false;
                    scrollView.Scroll(-0.01f);
                }
            }
            else
            {
                backwardButton.isEnabled = true;
                backScroll = true;
            }
        }

        if (forwardButton != null)
        {
            if (_lastIndex >= 0)
            {
                _lastItemPos = scrollView.draggablePanel.movement == UIScrollView.Movement.Horizontal ?
                               UICamera.mainCamera.WorldToScreenPoint(_widgets[_lastIndex].transform.position).x :
                               UICamera.mainCamera.WorldToScreenPoint(_widgets[_lastIndex].transform.position).y;
                forwardButton.isEnabled =
                    scrollView.draggablePanel.movement == UIScrollView.Movement.Horizontal ?
                    _lastItemPos > _forwardPos - scrollView.spacing * 0.1f :
                    _lastItemPos < _forwardPos + scrollView.spacing * 0.1f;

                if (!forwardButton.isEnabled && forwScroll)
                {
                    forwScroll = false;
                    scrollView.Scroll(0.01f);
                }
            }
            else
            {
                forwardButton.isEnabled = true;
                forwScroll = true;
            }
        }
    }
コード例 #2
0
 void Update()
 {
     if (_pressed)           //Scroll when pressed
     {
         targetCycler.Scroll(scrollSpeed);
     }
 }