ListView mousewheel scrolling speed

In my application, ListViews (UIToolkit runtime 2021.2.0b10) scroll extremely slowly with the mousewheel. I’m not finding a way how to adjust the speed of the scrolling.

According to the documentation, ScrollViews have the “VerticalPageSize” attribute that is supposed to control exactly that, but this parameter is not available in ListViews.

Nevertheless, even changing VerticalPageSize in ScrollViews doesn’t have any effect on the scrolling speed either.

Am I missing something, or is it “a work in progress”-topic?

1 Like

What value do you use? Mine is set to 1000.

For ScrollView, it doesn’t matter, what I set, it doesn’t have any impact (I just tried 1000 - no difference).

In ListView I don’t have any value to set.

It seems to work with 2021.2.0b6 so it must be a recent regression. I reported the case (#1364827) and will post the link to it when it becomes available (will take a few days).

I guess you mean here the VerticalPageSize parameter of the ScrollView. That is one issue. Thanks for filing a bug report.

The other issue is the slow scrolling of ListViews. Can you please confirm that I’m not missing something when I don’t find a way to change the scroll speed of ListViews?

I investigated with the team and here’s the answer I got:

We’ve had a regression on scrolling recently caused by changes to page size, and basically realized that scrolling should not depend on page size. It should always scroll the same amount regardless of the size of the viewport/content. So now we depend on line height. Users can override --unity-metrics-single_line-height in uss on their ScrollView/ListView to change the sensitivity. Default is 18px.

Also, in the future we’ll make single line height adjustable from the code as well.

Thank you for this information. Redeclaring the USS variable --unity-metrics-single_line-height in my custom stylesheet did the trick:

:root {
–unity-metrics-single_line-height: 500px;
}

In my case, 500px give a natural scrolling experience. One scroll step moves about one line of the list at 30px item height.

2 Likes

Since updateing to The beta we have the same bug.

But on 2021.2.0b15 the workaround seams not to change anything.
No matter what value I set --unity-metrics-single_line-height to, the scroll-speed does not change.

1 Like

Hi, I am having a similar issue can’t sense scrolling speed. Is there any more new information? I am using 2021.2.0f1

I managed to make it work with a custom callback!

[SerializeField] private UIDocument uiDocument;

private float scrollVelocity;
private float scrollDamping = 0.1f;
private Scroller verticalScroller;

private void Start () {
    var rootElement = uiDocument.rootVisualElement
    var list = rootElement.Q<ListView>("List");
  
    verticalScroller = list.Q("unity-content-and-vertical-scroll-container").Q<Scroller>();
  
    list.RegisterCallback<WheelEvent>(@event => {
        scrollVelocity += @event.delta.y * 100;

        // Stop the event here so the builtin scroll functionality of the list doesn't activate
        @event.StopPropagation();
    });
}

private void Update () {
    if (verticalScroller != null) {
        verticalScroller.value += scrollVelocity;
        scrollVelocity -= scrollVelocity * scrollDamping;
    }
}
2 Likes

Any updates here?
It is a real pain :confused:

:root {
–unity-metrics-single_line-height: 500px;
}

does not work for me either :frowning:

In Unity 2021.2.10f1 I still have trouble setting scrollspeed with ScrollView and ListViews its always veeeery slow :frowning:

1 Like

Also having this problem. Changing --unity-metrics-single_line-height does nothing. Why is there no communication on this?

1 Like

Setting --unity-metrics-single_line-height used to work with 2021.2.0b10 but as others reported, it stopped working with later versions. With 2021.2.11f1 still no luck.

Found the problem.

Before 2021.2.0b15 it used to be enough to set the key --unity-metrics-single_line-height on the root visual element. In later Unity versions, the key must be applied to the parent of the root visual item, which is in my case (runtime) the Panel Settings (check it in the Toolkit Debugger).

I didn’t find a way to do this in the UI Builder directly, so I add my stylesheet also to the parent per script on startup:

StyleSheet styleSheet = Resources.Load<StyleSheet>("UI/UI-Main");
            if (styleSheet != null)
                root.parent.styleSheets.Add(styleSheet);

where root is uiDocument.rootVisualElement.

Now, :root {
–unity-metrics-single_line-height: 500px;
} in the stylesheet is applied correctly.

The scrolling is fast again. :slight_smile:

3 Likes

Yes, this does appear to work. Thanks!

@AlexandreT-unity

This seems to not work in the latest beta 9. I reported the bug. Is there any insight into what is going on? Case #: 1403738

You are my HERO! Thanks this works!

2021.2.7f1 here and this doesn’t work for us (using rootVisualElement or rootVisualElement.parent of runtime UI Document). Our setup has two UI Documents if that makes any difference. Would really appreciate some input from the team on how to make this usable - I had hoped it would be fixed by now - it’s an incredibly painful issue.

https://issuetracker.unity3d.com/issues/ui-toolkit-slow-scroll-view-scrolling-when-entering-play-mode