PickerScrollRect

This is a class to manage one column (or one row) of picker. Handles control of items and scrolls.It inherits UnityEngine.ScrollRect and has equivalent functionality.

Function to get the selected item

Name

Description

GetSelectedPickerItem()

Returns the PickerItem attached to the currently selected item.It is a functional version of selectedPickerItem.

selectedPickerItem

PickerItem attached to the currently selected item.This is the property version of GetSelectedPickerItem().

GetSelectedItem()

Returns the GameObject of the currently selected item. It is a functional version of selectedItem.

selectedItem

GameObject of the currently selected item. Property version of GetSelectedItem().

Scroll function

Name

Description

ScrollToItemAtIndex( int index, bool immdiate = false )

Scroll to the index th item. When immdiate is true, scrolling is instantaneous.

ScrollTo( PickerItem item, bool immdiate = false )

Scroll to item. When immdiate is true, scrolling is instantaneous.

ScrollTo( float offset, bool immdiate = false )

Scroll to position offset.
Offset is PickerItem.position, GetScrollPosition (), firstItemPosition Can be obtained from etc.

ScrollToNearItem( bool immdiate = false )

Scroll to the nearest item. When immdiate is true, scrolling is instantaneous.

Function to get the state

Name

Description

itemCount

Number of items the picker has.

GetScrollPosition()

Get current scroll position.

firstItemPosition

Get the scroll position of the first item.

lastItemPosition

Gets the scroll position of the last item.

infiniteScroll

Get enable or disable of infinite scroll.

GetNearItemIndex()

Get the index of the nearest item.

Event

Name

Description

onSelectItem

This is an event sent when an item is selected.
You can change the send timing with whenToSendEvents.
For more information about events, please see https://docs.unity3d.com/Manual/UnityEvents.html .

Note

Events are sent from LateUpdate().
Function to get or set the value

Name

Description

layout

Get or set the scroll direction.
You can get / set any of RectTransform.Axis.Horizontal, RectTransform.Axis.Vertical.

autoScrollSeconds

When you tap an item, it takes time to scroll to that item.

slipVelocityRate

Stop the slip and scroll to the nearest item if the speed falls below this percentage.

wheelEffect

Reproduces the visual effect of placing the item on the wheel. Reduce the size of the item according to the distance from the center of the Column.

wheelPerspective

Set the depth of the wheel effect.

movementType

The behavior when content moves beyond the scroll rectangle.
Unrestricted: Loop infinitely.
Elastic: It behaves like elasticity.
Clamped: Stop.

initialPosition

Set the initial state of the scroll.

whenToSendEvents

When to send an event.
Always: Always send an OnSelectItem event whenever an item changes.
OnlyScrollStops: Sends an OnSelectItem event only when items have changed and scrolling has stopped.

enabledMouseControl

Get or set control with mouse/finger.

Note

The above values can also be set from the inspector.
Also, the behavior of the parameters on the inspector can be confirmed in the demo below.
Assets/PickerForUGUI/Demo/ParameterDemo.unity