- Home /
Inverted scrollrect
Hi! I have a bunch of buttons that are being aranged by a GridLayoutGroup. Attactched to that parent object i have a scrollbar with a scrollrect. Everything works just fine, I can scroll it and the buttons move around just as I wanted them to. The only problem is that the scrolling is inverted. Drag the mouse up and the scrollbar moves down and move the mouse down and the scrollbar moves up. I've tried adjusting the sensitivity to a negative value but the sensitivity makes no difference to the direction and not even the speed! What am I doing wrong? Thanks in regards!
Btw, I cannot find any other topic than “Strange IOC”, I don’t even know what that means but I had to enter a topic...
I remember having similar behaviour, and I think I fixed it by changing the Direction of the Scrollbars to the opposite (e.g. changed "Left To Right" to "Right to Left"). Have you tried this?
Yes, I did try that but then the slider is at the bottom when the content is at the top. It feels kind of weird to have the content move in the opposite direction of the slider so I whould really like if it was possible to do it in another way...
O$$anonymous$$, I just checked this, and I think the problem you perceive is actually the correct behaviour.
Think about it: if you have a scrollbar with Top to Bottom direction, then when you view the top, it should be at the top, and similarly for the other way around. When you drag moving the mouse up, you drag the viewed content up to see more of the bottom - hence the scrollbar needs to move towards the bottom.
Does this make sense? And did I understand your problem correctly?
Answer by huulong · Dec 29, 2021 at 07:55 PM
I got this on UI Toolkit Scroller. The child Slider automatically set Inverted to true despite the scroller being Horizontal (Scroller.cs code constructor says it should only be Inverted when vertical). I don't know if that applies to your case, but I suspect some behaviours are common between UI and UI Toolkit.
EDIT after reading comments: to be clear, the behaviour was definitely wrong, as the scroller was Horizontal, not Vertical, and clicking on the left arrow moved the slider to the right, and vice-versa.
I have reported the bug for UI Toolkit (for Editor window).
In the meantime, my workaround is to set myScroller.slider.inverted = false manually after UI elements construction when the scroller is horizontal. Maybe it will work with your UI system too.
Your answer
Follow this Question
Related Questions
Call Functions On Player From Canvas Elements In a Multiplayer Game 1 Answer
While loop not updating 1 Answer
Button.Select(); does not highlight? 12 Answers
AddListener not working c# 0 Answers
How do I call a ui buttons for google play services 0 Answers