Class Scrollbar
Implements
Inherited Members
Namespace: UnityEngine.UI
Assembly: UnityEngine.UI.dll
Syntax
[AddComponentMenu("UI/Scrollbar", 36)]
[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
public class Scrollbar : Selectable, IMoveHandler, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler, IBeginDragHandler, IDragHandler, IInitializePotentialDragHandler, IEventSystemHandler, ICanvasElement
Constructors
Scrollbar()
Declaration
protected Scrollbar()
Properties
direction
The direction of the scrollbar from minimum to maximum value.
Declaration
public Scrollbar.Direction direction { get; set; }
Property Value
Type | Description |
---|---|
Scrollbar.Direction |
handleRect
The RectTransform to use for the handle.
Declaration
public RectTransform handleRect { get; set; }
Property Value
Type | Description |
---|---|
RectTransform |
numberOfSteps
The number of steps to use for the value. A value of 0 disables use of steps.
Declaration
public int numberOfSteps { get; set; }
Property Value
Type | Description |
---|---|
int |
onValueChanged
Handling for when the scrollbar value is changed.
Declaration
public Scrollbar.ScrollEvent onValueChanged { get; set; }
Property Value
Type | Description |
---|---|
Scrollbar.ScrollEvent |
Remarks
Allow for delegate-based subscriptions for faster events than 'eventReceiver', and allowing for multiple receivers.
size
The size of the scrollbar handle where 1 means it fills the entire scrollbar.
Declaration
public float size { get; set; }
Property Value
Type | Description |
---|---|
float |
value
The current value of the scrollbar, between 0 and 1.
Declaration
public float value { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
ClickRepeat(PointerEventData)
Declaration
protected IEnumerator ClickRepeat(PointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | eventData |
Returns
Type | Description |
---|---|
IEnumerator |
ClickRepeat(Vector2, Camera)
Coroutine function for handling continual press during Scrollbar.OnPointerDown.
Declaration
protected IEnumerator ClickRepeat(Vector2 screenPosition, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | screenPosition | |
Camera | camera |
Returns
Type | Description |
---|---|
IEnumerator |
FindSelectableOnDown()
Prevents selection if we we move on the Vertical axis. See Selectable.FindSelectableOnDown.
Declaration
public override Selectable FindSelectableOnDown()
Returns
Type | Description |
---|---|
Selectable |
Overrides
FindSelectableOnLeft()
Prevents selection if we we move on the Horizontal axis. See Selectable.FindSelectableOnLeft.
Declaration
public override Selectable FindSelectableOnLeft()
Returns
Type | Description |
---|---|
Selectable |
Overrides
FindSelectableOnRight()
Prevents selection if we we move on the Horizontal axis. See Selectable.FindSelectableOnRight.
Declaration
public override Selectable FindSelectableOnRight()
Returns
Type | Description |
---|---|
Selectable |
Overrides
FindSelectableOnUp()
Prevents selection if we we move on the Vertical axis. See Selectable.FindSelectableOnUp.
Declaration
public override Selectable FindSelectableOnUp()
Returns
Type | Description |
---|---|
Selectable |
Overrides
GraphicUpdateComplete()
See ICanvasElement.GraphicUpdateComplete.
Declaration
public virtual void GraphicUpdateComplete()
LayoutComplete()
See ICanvasElement.LayoutComplete.
Declaration
public virtual void LayoutComplete()
OnBeginDrag(PointerEventData)
Handling for when the scrollbar value is begin being dragged.
Declaration
public virtual void OnBeginDrag(PointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | eventData |
OnDisable()
Declaration
protected override void OnDisable()
Overrides
OnDrag(PointerEventData)
Handling for when the scrollbar value is dragged.
Declaration
public virtual void OnDrag(PointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | eventData |
OnEnable()
Declaration
protected override void OnEnable()
Overrides
OnInitializePotentialDrag(PointerEventData)
See: IInitializePotentialDragHandler.OnInitializePotentialDrag
Declaration
public virtual void OnInitializePotentialDrag(PointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | eventData |
OnMove(AxisEventData)
Handling for movement events.
Declaration
public override void OnMove(AxisEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
AxisEventData | eventData |
Overrides
OnPointerDown(PointerEventData)
Event triggered when pointer is pressed down on the scrollbar.
Declaration
public override void OnPointerDown(PointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | eventData |
Overrides
OnPointerUp(PointerEventData)
Event triggered when pointer is released after pressing on the scrollbar.
Declaration
public override void OnPointerUp(PointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | eventData |
Overrides
OnRectTransformDimensionsChange()
This callback is called when the dimensions of an associated RectTransform change. It is always called before Awake, OnEnable, or Start. The call is also made to all child RectTransforms, regardless of whether their dimensions change (which depends on how they are anchored).
Declaration
protected override void OnRectTransformDimensionsChange()
Overrides
OnValidate()
Declaration
protected override void OnValidate()
Overrides
Rebuild(CanvasUpdate)
Rebuild the element for the given stage.
Declaration
public virtual void Rebuild(CanvasUpdate executing)
Parameters
Type | Name | Description |
---|---|---|
CanvasUpdate | executing | The current CanvasUpdate stage being rebuild. |
SetDirection(Direction, bool)
Set the direction of the scrollbar, optionally setting the layout as well.
Declaration
public void SetDirection(Scrollbar.Direction direction, bool includeRectLayouts)
Parameters
Type | Name | Description |
---|---|---|
Scrollbar.Direction | direction | The direction of the scrollbar. |
bool | includeRectLayouts | Should the layout be flipped together with the direction? |
SetValueWithoutNotify(float)
Set the value of the scrollbar without invoking onValueChanged callback.
Declaration
public virtual void SetValueWithoutNotify(float input)
Parameters
Type | Name | Description |
---|---|---|
float | input | The new value for the scrollbar. |
Update()
Update the rect based on the delayed update visuals. Got around issue of calling sendMessage from onValidate.
Declaration
protected virtual void Update()