NGUI: Next-Gen UI kit  3.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
UIScrollView Class Reference

This script, when attached to a panel turns it into a scroll view. You can then attach UIDragScrollView to colliders within to make it draggable. More...

Inheritance diagram for UIScrollView:

Public Types

enum  Movement { Movement.Horizontal, Movement.Vertical, Movement.Unrestricted, Movement.Custom }
 
enum  DragEffect { DragEffect.None, DragEffect.Momentum, DragEffect.MomentumAndSpring }
 
enum  ShowCondition { ShowCondition.Always, ShowCondition.OnlyIfNeeded, ShowCondition.WhenDragging }
 

Public Member Functions

delegate void OnDragNotification ()
 
bool RestrictWithinBounds (bool instant)
 Restrict the scroll view's contents to be within the scroll view's bounds. More...
 
bool RestrictWithinBounds (bool instant, bool horizontal, bool vertical)
 Restrict the scroll view's contents to be within the scroll view's bounds. More...
 
void DisableSpring ()
 Disable the spring movement. More...
 
void UpdateScrollbars ()
 Update the values of the associated scroll bars. More...
 
virtual void UpdateScrollbars (bool recalculateBounds)
 Update the values of the associated scroll bars. More...
 
virtual void SetDragAmount (float x, float y, bool updateScrollbars)
 Changes the drag amount of the scroll view to the specified 0-1 range values. (0, 0) is the top-left corner, (1, 1) is the bottom-right. More...
 
void InvalidateBounds ()
 Manually invalidate the scroll view's bounds so that they update next time. More...
 
void ResetPosition ()
 Reset the scroll view's position to the top-left corner. It's recommended to call this function before AND after you re-populate the scroll view's contents (ex: switching window tabs). Another option is to populate the scroll view's contents, reset its position, then call this function to reposition the clipping. More...
 
void UpdatePosition ()
 Call this function after you adjust the scroll view's bounds if you want it to maintain the current scrolled position More...
 
void OnScrollBar ()
 Triggered by the scroll bars when they change. More...
 
virtual void MoveRelative (Vector3 relative)
 Move the scroll view by the specified local space amount. More...
 
void MoveAbsolute (Vector3 absolute)
 Move the scroll view by the specified world space amount. More...
 
void Press (bool pressed)
 Create a plane on which we will be performing the dragging. More...
 
void Drag ()
 Drag the object along the plane. More...
 
void Scroll (float delta)
 If the object should support the scroll wheel, do it. More...
 

Public Attributes

Movement movement = Movement.Horizontal
 Type of movement allowed by the scroll view. More...
 
DragEffect dragEffect = DragEffect.MomentumAndSpring
 Effect to apply when dragging. More...
 
bool restrictWithinPanel = true
 Whether the dragging will be restricted to be within the scroll view's bounds. More...
 
bool disableDragIfFits = false
 Whether dragging will be disabled if the contents fit. More...
 
bool smoothDragStart = true
 Whether the drag operation will be started smoothly, or if if it will be precise (but will have a noticeable "jump"). More...
 
bool iOSDragEmulation = true
 Whether to use iOS drag emulation, where the content only drags at half the speed of the touch/mouse movement when the content edge is within the clipping area. More...
 
float scrollWheelFactor = 0.25f
 Effect the scroll wheel will have on the momentum. More...
 
float momentumAmount = 35f
 How much momentum gets applied when the press is released after dragging. More...
 
UIProgressBar horizontalScrollBar
 Horizontal scrollbar used for visualization. More...
 
UIProgressBar verticalScrollBar
 Vertical scrollbar used for visualization. More...
 
ShowCondition showScrollBars = ShowCondition.OnlyIfNeeded
 Condition that must be met for the scroll bars to become visible. More...
 
Vector2 customMovement = new Vector2(1f, 0f)
 Custom movement, if the 'movement' field is set to 'Custom'. More...
 
UIWidget.Pivot contentPivot = UIWidget.Pivot.TopLeft
 Content's pivot point – where it originates from by default. More...
 
OnDragNotification onDragStarted
 Event callback to trigger when the drag process begins. More...
 
OnDragNotification onDragFinished
 Event callback to trigger when the drag process finished. Can be used for additional effects, such as centering on some object. More...
 
OnDragNotification onMomentumMove
 Event callback triggered when the scroll view is moving as a result of momentum in between of OnDragFinished and OnStoppedMoving. More...
 
OnDragNotification onStoppedMoving
 Event callback to trigger when the scroll view's movement ends. More...
 
UICenterOnChild centerOnChild = null
 

Static Public Attributes

static BetterList< UIScrollViewlist = new BetterList<UIScrollView>()
 

Protected Member Functions

virtual void Start ()
 Set the initial drag value and register the listener delegates. More...
 
void UpdateScrollbars (UIProgressBar slider, float contentMin, float contentMax, float contentSize, float viewSize, bool inverted)
 Helper function used in UpdateScrollbars(float) function above. More...
 

Protected Attributes

Transform mTrans
 
UIPanel mPanel
 
Plane mPlane
 
Vector3 mLastPos
 
bool mPressed = false
 
Vector3 mMomentum = Vector3.zero
 
float mScroll = 0f
 
Bounds mBounds
 
bool mCalculatedBounds = false
 
bool mShouldMove = false
 
bool mIgnoreCallbacks = false
 
int mDragID = -10
 
Vector2 mDragStartOffset = Vector2.zero
 
bool mDragStarted = false
 

Properties

UIPanel panel [get]
 Panel that's being dragged. More...
 
bool isDragging [get]
 Whether the scroll view is being dragged. More...
 
virtual Bounds bounds [get]
 Calculate the bounds used by the widgets. More...
 
bool canMoveHorizontally [get]
 Whether the scroll view can move horizontally. More...
 
bool canMoveVertically [get]
 Whether the scroll view can move vertically. More...
 
virtual bool shouldMoveHorizontally [get]
 Whether the scroll view should be able to move horizontally (contents don't fit). More...
 
virtual bool shouldMoveVertically [get]
 Whether the scroll view should be able to move vertically (contents don't fit). More...
 
virtual bool shouldMove [get]
 Whether the contents of the scroll view should actually be draggable depends on whether they currently fit or not. More...
 
Vector3 currentMomentum [get, set]
 Current momentum, exposed just in case it's needed. More...
 

Detailed Description

This script, when attached to a panel turns it into a scroll view. You can then attach UIDragScrollView to colliders within to make it draggable.

Member Enumeration Documentation

Enumerator
None 
Momentum 
MomentumAndSpring 
Enumerator
Horizontal 
Vertical 
Unrestricted 
Custom 
Enumerator
Always 
OnlyIfNeeded 
WhenDragging 

Member Function Documentation

void UIScrollView.DisableSpring ( )

Disable the spring movement.

void UIScrollView.Drag ( )

Drag the object along the plane.

void UIScrollView.InvalidateBounds ( )

Manually invalidate the scroll view's bounds so that they update next time.

void UIScrollView.MoveAbsolute ( Vector3  absolute)

Move the scroll view by the specified world space amount.

virtual void UIScrollView.MoveRelative ( Vector3  relative)
virtual

Move the scroll view by the specified local space amount.

delegate void UIScrollView.OnDragNotification ( )
void UIScrollView.OnScrollBar ( )

Triggered by the scroll bars when they change.

void UIScrollView.Press ( bool  pressed)

Create a plane on which we will be performing the dragging.

void UIScrollView.ResetPosition ( )

Reset the scroll view's position to the top-left corner. It's recommended to call this function before AND after you re-populate the scroll view's contents (ex: switching window tabs). Another option is to populate the scroll view's contents, reset its position, then call this function to reposition the clipping.

bool UIScrollView.RestrictWithinBounds ( bool  instant)

Restrict the scroll view's contents to be within the scroll view's bounds.

bool UIScrollView.RestrictWithinBounds ( bool  instant,
bool  horizontal,
bool  vertical 
)

Restrict the scroll view's contents to be within the scroll view's bounds.

void UIScrollView.Scroll ( float  delta)

If the object should support the scroll wheel, do it.

virtual void UIScrollView.SetDragAmount ( float  x,
float  y,
bool  updateScrollbars 
)
virtual

Changes the drag amount of the scroll view to the specified 0-1 range values. (0, 0) is the top-left corner, (1, 1) is the bottom-right.

virtual void UIScrollView.Start ( )
protectedvirtual

Set the initial drag value and register the listener delegates.

void UIScrollView.UpdatePosition ( )

Call this function after you adjust the scroll view's bounds if you want it to maintain the current scrolled position

void UIScrollView.UpdateScrollbars ( )

Update the values of the associated scroll bars.

virtual void UIScrollView.UpdateScrollbars ( bool  recalculateBounds)
virtual

Update the values of the associated scroll bars.

void UIScrollView.UpdateScrollbars ( UIProgressBar  slider,
float  contentMin,
float  contentMax,
float  contentSize,
float  viewSize,
bool  inverted 
)
protected

Helper function used in UpdateScrollbars(float) function above.

Member Data Documentation

UICenterOnChild UIScrollView.centerOnChild = null
UIWidget.Pivot UIScrollView.contentPivot = UIWidget.Pivot.TopLeft

Content's pivot point – where it originates from by default.

Vector2 UIScrollView.customMovement = new Vector2(1f, 0f)

Custom movement, if the 'movement' field is set to 'Custom'.

bool UIScrollView.disableDragIfFits = false

Whether dragging will be disabled if the contents fit.

DragEffect UIScrollView.dragEffect = DragEffect.MomentumAndSpring

Effect to apply when dragging.

UIProgressBar UIScrollView.horizontalScrollBar

Horizontal scrollbar used for visualization.

bool UIScrollView.iOSDragEmulation = true

Whether to use iOS drag emulation, where the content only drags at half the speed of the touch/mouse movement when the content edge is within the clipping area.

BetterList<UIScrollView> UIScrollView.list = new BetterList<UIScrollView>()
static
Bounds UIScrollView.mBounds
protected
bool UIScrollView.mCalculatedBounds = false
protected
int UIScrollView.mDragID = -10
protected
bool UIScrollView.mDragStarted = false
protected
Vector2 UIScrollView.mDragStartOffset = Vector2.zero
protected
bool UIScrollView.mIgnoreCallbacks = false
protected
Vector3 UIScrollView.mLastPos
protected
Vector3 UIScrollView.mMomentum = Vector3.zero
protected
float UIScrollView.momentumAmount = 35f

How much momentum gets applied when the press is released after dragging.

Movement UIScrollView.movement = Movement.Horizontal

Type of movement allowed by the scroll view.

UIPanel UIScrollView.mPanel
protected
Plane UIScrollView.mPlane
protected
bool UIScrollView.mPressed = false
protected
float UIScrollView.mScroll = 0f
protected
bool UIScrollView.mShouldMove = false
protected
Transform UIScrollView.mTrans
protected
OnDragNotification UIScrollView.onDragFinished

Event callback to trigger when the drag process finished. Can be used for additional effects, such as centering on some object.

OnDragNotification UIScrollView.onDragStarted

Event callback to trigger when the drag process begins.

OnDragNotification UIScrollView.onMomentumMove

Event callback triggered when the scroll view is moving as a result of momentum in between of OnDragFinished and OnStoppedMoving.

OnDragNotification UIScrollView.onStoppedMoving

Event callback to trigger when the scroll view's movement ends.

bool UIScrollView.restrictWithinPanel = true

Whether the dragging will be restricted to be within the scroll view's bounds.

float UIScrollView.scrollWheelFactor = 0.25f

Effect the scroll wheel will have on the momentum.

ShowCondition UIScrollView.showScrollBars = ShowCondition.OnlyIfNeeded

Condition that must be met for the scroll bars to become visible.

bool UIScrollView.smoothDragStart = true

Whether the drag operation will be started smoothly, or if if it will be precise (but will have a noticeable "jump").

UIProgressBar UIScrollView.verticalScrollBar

Vertical scrollbar used for visualization.

Property Documentation

virtual Bounds UIScrollView.bounds
get

Calculate the bounds used by the widgets.

bool UIScrollView.canMoveHorizontally
get

Whether the scroll view can move horizontally.

bool UIScrollView.canMoveVertically
get

Whether the scroll view can move vertically.

Vector3 UIScrollView.currentMomentum
getset

Current momentum, exposed just in case it's needed.

bool UIScrollView.isDragging
get

Whether the scroll view is being dragged.

UIPanel UIScrollView.panel
get

Panel that's being dragged.

virtual bool UIScrollView.shouldMove
getprotected

Whether the contents of the scroll view should actually be draggable depends on whether they currently fit or not.

virtual bool UIScrollView.shouldMoveHorizontally
get

Whether the scroll view should be able to move horizontally (contents don't fit).

virtual bool UIScrollView.shouldMoveVertically
get

Whether the scroll view should be able to move vertically (contents don't fit).


The documentation for this class was generated from the following file: