Search code examples
unity-game-enginescrollviewngui

How use Button in ScrollView in NGUI to scroll the object


I made the Scrollable View in NGUI using following tutorials Here but how can I use button to scroll the objects. Like If i click on up button it ScrollView should be up and If i click on down ScrollView should be down.

Your help will be appreciated. Thanks.

enter image description here


Solution

  • You can do two different things to have scrolling button, depending what do you mean.

    1. If you want to have a scroll button, you should create UIScrollBar component, which you will attach to you UIScrollView as a horizontal or vertical scroll bar. See NGUI examples included to the package.
    2. If you want to have a object on your list, which clicked will allow you to drag the UIScrollView, you should attach to this gameObject a UIDragScrollView component. It will allow you to drag-to-scroll behavior, similar to mobile list dragging experience. Again, such example should be included to the package.

    EDIT: After your question clarification, the answer should be a bit different.

    You should write a script, with a reference to your UIScrollView and then you should call on it MoveRelative( Vector3 relative ) or MoveAbsolute( Vector3 absolute ), which will move the scroll view.