docs.unity.cn
    Show / Hide Table of Contents

    Class Scrollbar

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    UIBehaviour
    Selectable
    Scrollbar
    Inherited Members
    Selectable.s_Selectables
    Selectable.s_SelectableCount
    Selectable.allSelectablesArray
    Selectable.allSelectableCount
    Selectable.allSelectables
    Selectable.AllSelectablesNoAlloc(Selectable[])
    Selectable.m_CurrentIndex
    Selectable.navigation
    Selectable.transition
    Selectable.colors
    Selectable.spriteState
    Selectable.animationTriggers
    Selectable.targetGraphic
    Selectable.interactable
    Selectable.image
    Selectable.Awake()
    Selectable.OnCanvasGroupChanged()
    Selectable.IsInteractable()
    Selectable.OnDidApplyAnimationProperties()
    Selectable.OnTransformParentChanged()
    Selectable.currentSelectionState
    Selectable.InstantClearState()
    Selectable.DoStateTransition(Selectable.SelectionState, Boolean)
    Selectable.FindSelectable(Vector3)
    Selectable.IsHighlighted()
    Selectable.IsPressed()
    Selectable.OnPointerEnter(PointerEventData)
    Selectable.OnPointerExit(PointerEventData)
    Selectable.OnSelect(BaseEventData)
    Selectable.OnDeselect(BaseEventData)
    Selectable.Select()
    UIBehaviour.Start()
    UIBehaviour.OnDestroy()
    UIBehaviour.IsActive()
    UIBehaviour.OnBeforeTransformParentChanged()
    UIBehaviour.OnCanvasHierarchyChanged()
    UIBehaviour.IsDestroyed()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(String, Single)
    MonoBehaviour.InvokeRepeating(String, Single, Single)
    MonoBehaviour.CancelInvoke(String)
    MonoBehaviour.IsInvoking(String)
    MonoBehaviour.StartCoroutine(String)
    MonoBehaviour.StartCoroutine(String, Object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(String)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(Object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, Component)
    Component.TryGetComponent<T>(T)
    Component.GetComponent(String)
    Component.GetComponentInChildren(Type, Boolean)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(Boolean)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, Boolean)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(Boolean)
    Component.GetComponentsInChildren<T>(Boolean, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, Boolean)
    Component.GetComponentInParent(Type)
    UnityEngine.Component.GetComponentInParent<T>(System.Boolean)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, Boolean)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(Boolean)
    Component.GetComponentsInParent<T>(Boolean, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(String)
    Component.SendMessageUpwards(String, Object, SendMessageOptions)
    Component.SendMessageUpwards(String, Object)
    Component.SendMessageUpwards(String)
    Component.SendMessageUpwards(String, SendMessageOptions)
    Component.SendMessage(String, Object)
    Component.SendMessage(String)
    Component.SendMessage(String, Object, SendMessageOptions)
    Component.SendMessage(String, SendMessageOptions)
    Component.BroadcastMessage(String, Object, SendMessageOptions)
    Component.BroadcastMessage(String, Object)
    Component.BroadcastMessage(String)
    Component.BroadcastMessage(String, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, Boolean)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsSortMode)
    UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsInactive, UnityEngine.FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
    UnityEngine.Object.FindFirstObjectByType<T>()
    UnityEngine.Object.FindAnyObjectByType<T>()
    UnityEngine.Object.FindFirstObjectByType<T>(UnityEngine.FindObjectsInactive)
    UnityEngine.Object.FindAnyObjectByType<T>(UnityEngine.FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, Boolean)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: UnityEngine.UI
    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
    Int32

    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
    Single

    value

    The current value of the scrollbar, between 0 and 1.

    Declaration
    public float value { get; set; }
    Property Value
    Type Description
    Single

    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
    Selectable.FindSelectableOnDown()

    FindSelectableOnLeft()

    Prevents selection if we we move on the Horizontal axis. See Selectable.FindSelectableOnLeft.

    Declaration
    public override Selectable FindSelectableOnLeft()
    Returns
    Type Description
    Selectable
    Overrides
    Selectable.FindSelectableOnLeft()

    FindSelectableOnRight()

    Prevents selection if we we move on the Horizontal axis. See Selectable.FindSelectableOnRight.

    Declaration
    public override Selectable FindSelectableOnRight()
    Returns
    Type Description
    Selectable
    Overrides
    Selectable.FindSelectableOnRight()

    FindSelectableOnUp()

    Prevents selection if we we move on the Vertical axis. See Selectable.FindSelectableOnUp.

    Declaration
    public override Selectable FindSelectableOnUp()
    Returns
    Type Description
    Selectable
    Overrides
    Selectable.FindSelectableOnUp()

    GraphicUpdateComplete()

    See ICanvasElement.GraphicUpdateComplete.

    Declaration
    public virtual void GraphicUpdateComplete()
    Implements
    ICanvasElement.GraphicUpdateComplete()

    LayoutComplete()

    See ICanvasElement.LayoutComplete.

    Declaration
    public virtual void LayoutComplete()
    Implements
    ICanvasElement.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
    Implements
    IBeginDragHandler.OnBeginDrag(PointerEventData)

    OnDisable()

    Declaration
    protected override void OnDisable()
    Overrides
    Selectable.OnDisable()

    OnDrag(PointerEventData)

    Handling for when the scrollbar value is dragged.

    Declaration
    public virtual void OnDrag(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData
    Implements
    IDragHandler.OnDrag(PointerEventData)

    OnEnable()

    Declaration
    protected override void OnEnable()
    Overrides
    Selectable.OnEnable()

    OnInitializePotentialDrag(PointerEventData)

    See: IInitializePotentialDragHandler.OnInitializePotentialDrag

    Declaration
    public virtual void OnInitializePotentialDrag(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData
    Implements
    IInitializePotentialDragHandler.OnInitializePotentialDrag(PointerEventData)

    OnMove(AxisEventData)

    Handling for movement events.

    Declaration
    public override void OnMove(AxisEventData eventData)
    Parameters
    Type Name Description
    AxisEventData eventData
    Overrides
    Selectable.OnMove(AxisEventData)

    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
    Selectable.OnPointerDown(PointerEventData)

    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
    Selectable.OnPointerUp(PointerEventData)

    OnRectTransformDimensionsChange()

    Declaration
    protected override void OnRectTransformDimensionsChange()
    Overrides
    UIBehaviour.OnRectTransformDimensionsChange()

    Rebuild(CanvasUpdate)

    Declaration
    public virtual void Rebuild(CanvasUpdate executing)
    Parameters
    Type Name Description
    CanvasUpdate executing
    Implements
    ICanvasElement.Rebuild(CanvasUpdate)

    SetDirection(Scrollbar.Direction, Boolean)

    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.

    Boolean includeRectLayouts

    Should the layout be flipped together with the direction?

    SetValueWithoutNotify(Single)

    Set the value of the scrollbar without invoking onValueChanged callback.

    Declaration
    public virtual void SetValueWithoutNotify(float input)
    Parameters
    Type Name Description
    Single 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()

    Extension Methods

    UIBehaviourExtensions.InvokeOnEnable(UIBehaviour)
    UIBehaviourExtensions.InvokeOnDisable(UIBehaviour)
    UIBehaviourExtensions.InvokeAwake(UIBehaviour)
    UIBehaviourExtensions.InvokeRebuild(UIBehaviour, CanvasUpdate)
    UIBehaviourExtensions.InvokeLateUpdate(UIBehaviour)
    UIBehaviourExtensions.InvokeUpdate(UIBehaviour)
    UIBehaviourExtensions.InvokeOnRectTransformDimensionsChange(UIBehaviour)
    UIBehaviourExtensions.InvokeOnCanvasGroupChanged(UIBehaviour)
    UIBehaviourExtensions.InvokeOnDidApplyAnimationProperties(UIBehaviour)
    SelectableExtensions.InvokeOnPointerDown(Selectable, PointerEventData)
    SelectableExtensions.InvokeOnPointerUp(Selectable, PointerEventData)
    SelectableExtensions.InvokeOnPointerEnter(Selectable, PointerEventData)
    SelectableExtensions.InvokeOnPointerExit(Selectable, PointerEventData)
    SelectableExtensions.InvokeTriggerAnimation(Selectable, String)
    SelectableExtensions.InvokeOnSelect(Selectable, String)
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on 12 June 2023