FairyGUI.ScrollPane.ScrollToView C# (CSharp) Method

ScrollToView() public method

public ScrollToView ( Rect rect, bool ani, bool setFirst ) : void
rect Rect Rect in local coordinates
ani bool If moving to target position with animation
setFirst bool If true, scroll to make the target on the top/left; If false, scroll to make the target any position in view.
return void
        public void ScrollToView(Rect rect, bool ani, bool setFirst)
        {
            _owner.EnsureBoundsCorrect();
            if (_needRefresh)
                Refresh();

            if (_yOverlap > 0)
            {
                float bottom = _yPos + _viewHeight;
                if (setFirst || rect.y <= _yPos || rect.height >= _viewHeight)
                {
                    if (_pageMode)
                        this.SetPosY(Mathf.Floor(rect.y / _pageSize.y) * _pageSize.y, ani);
                    else
                        SetPosY(rect.y, ani);
                }
                else if (rect.y + rect.height > bottom)
                {
                    if (_pageMode)
                        this.SetPosY(Mathf.Floor(rect.y / _pageSize.y) * _pageSize.y, ani);
                    else if (rect.height <= _viewHeight / 2)
                        SetPosY(rect.y + rect.height * 2 - _viewHeight, ani);
                    else
                        SetPosY(rect.y + rect.height - _viewHeight, ani);
                }
            }
            if (_xOverlap > 0)
            {
                float right = _xPos + _viewWidth;
                if (setFirst || rect.x <= _xPos || rect.width >= _viewWidth)
                {
                    if (_pageMode)
                        this.SetPosX(Mathf.Floor(rect.x / _pageSize.x) * _pageSize.x, ani);
                    SetPosX(rect.x, ani);
                }
                else if (rect.x + rect.width > right)
                {
                    if (_pageMode)
                        this.SetPosX(Mathf.Floor(rect.x / _pageSize.x) * _pageSize.x, ani);
                    else if (rect.width <= _viewWidth / 2)
                        SetPosX(rect.x + rect.width * 2 - _viewWidth, ani);
                    else
                        SetPosX(rect.x + rect.width - _viewWidth, ani);
                }
            }

            if (!ani && _needRefresh)
                Refresh();
        }

Same methods

ScrollPane::ScrollToView ( GObject obj ) : void
ScrollPane::ScrollToView ( GObject obj, bool ani ) : void
ScrollPane::ScrollToView ( GObject obj, bool ani, bool setFirst ) : void