Unity-UI-Extensions.GitHub.io

ScrollSnap

An alternate scroll snap control supporting both Horizontal and Vertical layouts in one control


Contents

1 Overview

2 Properties

3 Methods

4 Usage

5 Video Demo

6 See also

7 Credits and Donation

8 External links


Overview

A scroll snap style control which works with both a horizontal and vertical layout, enabling a paged view of child elements. Pages can be moved by keys, swipes or via the use of buttons.

*Note, should not be used in conjunction with scroll bars as this throws off the view.


Properties

The properties of the Horizontal Scroll Snap control are as follows:

Property Description
Next Button Optional button to move the ScrollSnap forward.
Prev Button Optional button to move the ScrollSnap backward.
Items Visible at once How many items should be visible at the same time.
Auto Layout Items Should the ScrollSnap contents be automatically aligned, or left untouched.
Link Scrollbar Steps Use the base ScrollRect steps configuration for the ScrollSnap.
Link Scrollbar Scroll Sensitivity Use the base ScrollRect scroll sensitivity configuration for the ScrollSnap.
Use Fast Swipe Should “Fast Swipe” be used to progress pages.
Fast Swipe Threshold The speed of the ScrollSnap is moving before a “Fast Swipe” motion is detected.
Direction The direction the ScrollSnap flows in, Horizontal or Vertical.
On Page Change (event) The Event fired when the current page changes, either via swipe, mouse, Next/Prev Buttons

Methods

Method Arguments Description
ChangePage Index (int) Move the ScrollSNap to a specific page (0 indexed)
CurrentPage None Returns the Current Page selected for the ScrollSnap
NextScreen None Forces the control to move to the “Next” page
PreviousScreen None Forces the control to move to the “Previous” page
ResetPage None Resets the currently selected page to the starting page, usually page 0
SetLerp value (bool) Enable or disable smooth Lerp movement

Usage

Like with other Layout controls, simply add this to the parent RectTransform for a collection of child elements through the Add Component menu as follows: Add Component -> Layout -> Extensions -> ScrollSnap

Or alternatively, add one of the default layouts for the control using:


Video Demo

tutorial video


See also


Credits and Donation

BinaryX, xesenix


Sourced from