Home › Page › UghScrollView

UghScrollView

Inherits from UghControl

The UghScrollView is a scrollable list of Transforms.

This feature is in BETA right now. It may behave strangely right now, and we are working to fix any problems with it.

Variables
name type description
layoutDirection LayoutDirection Which direction the view scrolls.
elementSpacing float The spacing between elements, in Unity units.
scrollVelocityFalloff float The speed at which a scrolling view comes to rest.
enforcingVelocity float The speed at which the view snaps to back to the element in focus.
enforceEdges boolean If true, will enforce the edges of the view such that one element is always visible.
snapPoint Transform If snapPaging is enabled, this Transform will define the focus point to enforce the snap.
snapPaging boolean If true, will cause the element closest to the snapPoint to center on the snapPoint.
snapPagingTimeout float UNUSED
miniumSnapPagingSpeed float If snapPaging is enabled, the minimum speed the mouse/touch must move before the view is allowed to scroll, in pixels/second.
elementCount int The number of elements in the UghScrollView
Functions
name type description
AddElement void Add an element to the UghScrollView
RemoveElement void Remove an element from the UghScrollView
FindElementWithTransform UghScrollViewElement Finds an element in the UghScrollView and returns it
GetElementAtIndex UghScrollViewElement return the element in the UghScrollView at the specified index
AutoLayout void Automatically lays out the UghScrollView using the assigned variable information

_

Using UghScrollView in script

UghScrollView is primarily set up in the inspector view. For more info on how to set one up, see the tutorial here.

The UghScrollView can also be set up and handled dynamically in script.

UghScrollView Scripting Functions

public void AddElement(Transform obj)
public void AddElement(UghScrollViewElement element)
<em id="__mceDel">

Adds a Transform to the view surface.  This function will take the supplied Transform and wrap it in an UghScrollViewElement before adding it to the view.  An overloaded version exists if you already have access to an UghScrollViewElement instance.

public RemoveElement(UghScrollViewElement element)

This function removes the specified UghScrollViewElement from the view surface.  (Use FindElementWithTransform to look up an UghScrollViewElement.)

public UghScrollViewElement FindElementWithTransform(Transform search)

Searches all of the UghScrollViewElements in the view surface and returns the instance that contains a reference to the supplied Transform.  If none is found, this function will return null.

public UghScrollViewElement GetElementAtIndex(int index)

Given an index, this function will return the associated UghScrollViewElement.  If no element is associated with the index, the function will return null.  Note that the index reflects the order in which the UghScrollViewElement was added to the view surface, and has no relation to its position on in the view.

Using the AutoLayout function

UghScrollView has a context menu option “Auto Layout.”  Selecting this from the inspector’s context menu will cause the UghScrollView to sort and align its contents.  The sorting and alignment is based on the specified layoutDirection.  Note that this sorts the list of UghScrollViewElements, thus changing their index with respect to the GetElementAtIndex function.