Version: 2022.1
UXML element RepeatButton
UXML element Scroller

UXML element ScrollView

C# class: ScrollView
Namespace: UnityEngine.UIElements
Base class: VisualElement

Member attributes

This element has the following member attributes:

名称 类型 描述
elasticity float The amount of elasticity to use when a user tries to scroll past the boundaries of the scroll view.

Elasticity is only used when touchScrollBehavior is set to Elastic.
horizontal-page-size float This property is controlling the scrolling speed of the horizontal scroller.
horizontal-scroller-visibility UIElements.ScrollerVisibility Specifies whether the horizontal scroll bar is visible.
mode UIElements.ScrollViewMode Controls how the ScrollView allows the user to scroll the contents. ScrollViewMode

The default is ScrollViewMode.Vertical. Writing to this property modifies the class list of the ScrollView according to the specified value of ScrollViewMode. When the value changes, the class list matching the old value is removed and the class list matching the new value is added.
scroll-deceleration-rate float Controls the rate at which the scrolling movement slows after a user scrolls using a touch interaction.

The deceleration rate is the speed reduction per second. A value of 0.5 halves the speed each second. A value of 0 stops the scrolling immediately.
vertical-page-size float This property is controlling the scrolling speed of the vertical scroller.
vertical-scroller-visibility UIElements.ScrollerVisibility Specifies whether the vertical scroll bar is visible.

Inherited attributes

This element inherits the following attributes from its base class:

名称 类型 描述
focusable boolean True if the element can be focused.
tabindex int An integer used to sort focusables in the focus ring. Must be greater than or equal to zero.

This element also inherits the following attributes from VisualElement:

名称 类型 描述
content-container string child elements are added to this element, usually this
name string The name of this VisualElement.

Use this property to write USS selectors that target a specific element. The standard practice is to give an element a unique name.
picking-mode UIElements.PickingMode Determines if this element can be pick during mouseEvents or IPanel.Pick queries.
style string Reference to the style object of this element.

Contains data computed from USS files or inline styles written to this object in C#.
tooltip string Text to display inside an information box after the user hovers the element for a small amount of time.
usage-hints UIElements.UsageHints A combination of hint values that specify high-level intended usage patterns for the VisualElement. This property can only be set when the VisualElement is not yet part of a Panel. Once part of a Panel, this property becomes effectively read-only, and attempts to change it will throw an exception. The specification of proper UsageHints drives the system to make better decisions on how to process or accelerate certain operations based on the anticipated usage pattern. Note that those hints do not affect behavioral or visual results, but only affect the overall performance of the panel and the elements within. It’s advised to always consider specifying the proper UsageHints, but keep in mind that some UsageHints might be internally ignored under certain conditions (e.g. due to hardware limitations on the target platform).
view-data-key string Used for view data persistence (ie. tree expanded states, scroll position, zoom level).

This is the key used to save/load the view data from the view data store. Not setting this key will disable persistence for this VisualElement.

USS classes

The following table lists all the C# public property names and their related USS selector.

C# property USS selector 描述
ussClassName .unity-scroll-view USS class name of elements of this type.
viewportUssClassName .unity-scroll-view__content-viewport USS class name of viewport elements in elements of this type.
horizontalVariantViewportUssClassName .unity-scroll-view__content-viewport--horizontal USS class name that’s added when the Viewport is in horizontal mode. ScrollViewMode.Horizontal
verticalVariantViewportUssClassName .unity-scroll-view__content-viewport--vertical USS class name that’s added when the Viewport is in vertical mode. ScrollViewMode.Vertical
verticalHorizontalVariantViewportUssClassName .unity-scroll-view__content-viewport--vertical-horizontal USS class name that’s added when the Viewport is in both horizontal and vertical mode. ScrollViewMode.VerticalAndHorizontal
contentAndVerticalScrollUssClassName .unity-scroll-view__content-and-vertical-scroll-container USS class name of content elements in elements of this type.
contentUssClassName .unity-scroll-view__content-container USS class name of content elements in elements of this type.
horizontalVariantContentUssClassName .unity-scroll-view__content-container--horizontal USS class name that’s added when the ContentContainer is in horizontal mode. ScrollViewMode.Horizontal
verticalVariantContentUssClassName .unity-scroll-view__content-container--vertical USS class name that’s added when the ContentContainer is in vertical mode. ScrollViewMode.Vertical
verticalHorizontalVariantContentUssClassName .unity-scroll-view__content-container--vertical-horizontal USS class name that’s added when the ContentContainer is in both horizontal and vertical mode. ScrollViewMode.VerticalAndHorizontal
hScrollerUssClassName .unity-scroll-view__horizontal-scroller USS class name of horizontal scrollers in elements of this type.
vScrollerUssClassName .unity-scroll-view__vertical-scroller USS class name of vertical scrollers in elements of this type.
horizontalVariantUssClassName .unity-scroll-view--horizontal USS class name that’s added when the ScrollView is in horizontal mode. ScrollViewMode.Horizontal
verticalVariantUssClassName .unity-scroll-view--vertical USS class name that’s added when the ScrollView is in vertical mode. ScrollViewMode.Vertical
verticalHorizontalVariantUssClassName .unity-scroll-view--vertical-horizontal USS class name that’s added when the ScrollView is in both horizontal and vertical mode. ScrollViewMode.VerticalAndHorizontal
scrollVariantUssClassName .unity-scroll-view--scroll
disabledUssClassName .unity-disabled USS class name of local disabled elements.

You can also use the Matching Selectors section in the Inspector or the UI Toolkit Debugger to see which USS selectors affect the components of the visual element at every level of its hierarchy.

UXML element RepeatButton
UXML element Scroller