I’m adding visualElements under the container #TimelinePillList and #TimelineChildPillList via script. However, the parent ScrollView (VerticalAndHorizontal-mode and “Infinite” scrolling) scroll bars won’t reflect the new size of the the content - they simply won’t update. If I click the buttons at the sides of the scroll bar, I can make it scroll to the content when in Elastic or Infinite -scroll mode, but the scroll bar width and height (the bar itself) doesn’t update. Is there a way to force update the ScrollView UI, to tell it that it should check the new content width and height? It doesn’t seem to do this automatically.
It’s hard to tell without investigating the actual project. It seemed to work on my end (21.2.10f1), when I added nested VisualElements to a ScrollView. Are you using absolute positioning? If you suspect this is a bug, don’t hesitate to submit a repro through the bug reporter in Help > Report a bug…
Hi! Thanks for the quick reply. I query the #TimelinePillList inside the ScrollView and add elements to it. Yes, I’m using absolute positioning to add them inside the #TimelinePillList-container. Is this something that could cause the behaviour?
When setting the height of the nested VisualElement to 1000, the scroll bars don’t immediately appear, I had to save the UXML (which forces a reload). I’ll submit my repro through the bug reporter and post the case number here so you can track it.
Hmm, updating unity-content-container manually (via query and then unityContentContainerVisualElement.style.width = newWidth) doesn’t seem to force update. Is there a way (as a workaround) - to force the scrollbar reload by script?
Just for the follow-up - did you already get the case number for this? Did you happen to come up a workaround while waiting? Updating the content-container manually doesn’t make the scrollbars refresh. I still haven’t found a way to force them refresh.
Okay, found the workaround that was hinted at earlier.
Changing the size of the scroll view does the trick, however you may not set it to the value it already has. Here I just alternate it between “99.999%” and “100%”
I can solve this problem by using the asynchronous method of Dotween (http://dotween.demigiant.com/), which resets the height of the scroller after a delay of 0 seconds.
Am seeing that this ticket has been closed with “By Design”.
Well, what is the right way to solve the problem we encountered then?
Being able to dynamically change content of a scrollview in such a way that the scrollbars adapt feels rather fundamental to me. If not fully automated, at least provide some “EnforceRefresh” method please as the workaround is simply hacky and not reliable.
For example on lower resolutions, the “99.999f” is too little of a difference to trigger the refresh.
P.s. MarkDirtyRepaint does not work.
That flickers ugly as for one frame the element is nullified. On my side since at least.
I have a tab based panel layout, where each panel contains a scrollView.
Switch between panels removes and adds them to a parent container.
When switching panels, the scrollView contained within doesn’t update.
You can get into a situation where you’ve scrolled to the bottom of one panel, switch to another that wasn’t as tall, and the content is not visible, since the scrollView hasn’t updated its size.
The fix @AlexandreT-unity gave kinda works (still can get into a situation where the scrollView doesn’t update). But is this seriously what we’re expected to do?
If so, why isn’t this just part of the ScrollView class?
@stevphie123 what do you mean by scrollView set to wrap?
Apparenty I spoke too soon. Found a problem even with the proposed “fix”.
I have a scrollview initially filled with lots of elements (top left image). Then, clicking on a radio button, I clear it and populate with others (top right image). Just enough, so the scrollview doesn’t actually needs a scrollbar, so it disappears.
Then, if I change it back to show the first elements (bottom left), they all show up, but the vertical scrollbar won’t show.
If I change the scrollbar from ‘auto’ to ‘always visible’, it stays on screen, but it doesn’t update.