- Home /
Scrolling Scroll Rect with Buttons
I am trying to create something like the following for my level selection
So, I want to allow the player to scroll through the levels by clicking the left/right arrows.
By using Scroll Rect I can create something like this easily. However, I don't see a way to implement the buttons instead of a drag or scrollbar.
I tried creating two Buttons at a higher level than the Scroll Rect (so they aren't scrolled out of view as well).
However, I don't see what function I can call in my On Click in order to scroll the Scroll Rect.
Anyone know if this is possible?
Thank you
Answer by mingom · Feb 26, 2016 at 08:15 PM
use UI.ScrollRect.horizontalNormalizedPosition.
Or use a coroutine and lerp the UI.ScrollRect.horizontalNormalizedPosition for the size of one element on each click. Need more details?
Answer by Brijs · Jun 10, 2016 at 12:09 PM
Modify ScrollRect.velocity property as per your need when you click button.
Set ScrollRect.decelerationRate for smoothness as per your need.
or change position of content of scrollrect
Answer by jinincarnate · Apr 09, 2020 at 02:37 PM
Anyone still looking for answer I created a github repository with a sample scene. here