API

Public methods and their functionality.

ScrollSnap.cs

ScrollSnap Inspector UI

Content

Container for scroll snap pages.

public RectTransform Content;

ScrollSnapAxis

Axis of the pages. Can be set Horizontal or Vertical.

public RectTransform.Axis ScrollSnapAxis;

VerticalPageAlignment

Align the start of the pages to the top or to the bottom of the Content.

public VerticalAlignment VerticalPageAlignment;

HorizontalPageAlignment

Align the start of the pages to the left side or to the right side of the Content.

public HorizontalAlignment HorizontalPageAlignment;

ScrollOutMargin

Size of the side areas in pixels to scroll out of the first and the last pages. Used for giving an elastic feeling to the scrollable area.

public float ScrollOutMargin;

Scroll out margins are shown with orange gizmos on the ScrollSnap component. Changing the value of it will be reflected immediately to let you know how far you can scroll out. The default value is 100 pixels.

Scroll Out Margin area in red.

SnapAreaSize

The size of the center area in pixels which is necessary for activating the snap. If the next page enters this range page will snap. The default value is 200 pixels.

public float SnapAreaSize;

The snap area is shown with blue gizmos on the ScrollSnap component. Changing the value of it will be reflected immediately to let you know when snap will be active. The default value is 200 pixels.

Snap Area in red.

SnapSpeed

Speed of the snap after swipe gesture stops. The min value is 0 and the max value is 1.

public float SnapSpeed;

CurrentPageIndex

Index of the current page in the Content.

public int CurrentPageIndex;

ScrollAmount

Amount of the scroll from 0 to the number of pages.

public float ScrollAmount;

OnPageChanged

The Event is called when the page changes. Gives the changed index as a parameter to the callback.

public ScrollSnapEvent OnPageChanged;

PageWidth

Width of the ScrollSnap page.

public float PageWidth;

PageHeight

Height of the ScrollSnap page.

public float PageHeight;

ResetScrollSnapUI

Resets the page size and position. Should be called if the page count is changed during runtime.

public void ResetScrollSnapUI()

ScrollSnapInfinite.cs

Scroll Snap Infinite Inspector UI

Scroll Snap Infinite is a separate component for infinite scroll ability. API of this class is almost identical to the ScrollSnap component. However, it does not have the ScrollOutMargin variable since it is not needed.

IndexTable.cs

Index Table component in a Scroll Snap UI in red.

Index Table is a helper component that creates radio button-like behavior for switching pages. Buttons on it are auto-generated for the number of pages in the Scroll Snap component. It can only be used with the Scroll Snap component and not with infinite scroll.

Index Table component UI

ScrollSnap

The parent Scroll Snap component, that the Index Table will work with.

public ScrollSnap ScrollSnap;

ToggleSize

The size of the Toggle by height.

public float ToggleSize;

TogglePadding

The padding between the buttons of the Index Table.

public float TogglePadding;

Last updated

Was this helpful?