- Home /
Why are my scrollbars going to extremes when pressing their buttons?
With Unity version 2017.3, I am using GUI.VerticalScrollbar
and GUI.HorizontalScrollbar
in my custom editor (actually, a custom PropertyDrawer
; there is a good reason I'm not using utils like GUI.BeginScrollView
). However, when I use my scrollbars like this...
EditorGUI.BeginDisabledGroup(maxX == 0);
scrollX = (uint)GUI.HorizontalScrollbar(new Rect(xyPos + new Vector2(slHeight, availableWidth - slHeight), new Vector2(availableWidth - slHeight, slHeight)), scrollX, 1, 0, maxX + 1, GUI.skin.horizontalScrollbar);
EditorGUI.EndDisabledGroup();
EditorGUI.BeginDisabledGroup(maxY == 0);
scrollY = (uint)GUI.VerticalScrollbar(new Rect(xyPos, new Vector2(slHeight, availableWidth - slHeight)), scrollY, 1, maxY + 1, 0, GUI.skin.verticalScrollbar);
EditorGUI.EndDisabledGroup();
What I get is that, if I click either of the < > (for horizontal scrollbar) or ^ V (for vertical scrollbar), the scroll position goes to 0
or maxX
respectively for horizontal scrollbar, and maxY
or 0
respectively for vertical scrollbar. I don't get how to just move... by one, when clicking.
After adding some calls to Debug.LogFormat
I notice the movement from any position to any of those extreme positions is instantaneous. On the other hand, if I drag the scrollbar thumbs, I can go to the position I want. But this doesn't happen if I want to click any of the buttons: they move the thumb always to the extreme positions of the scrollbar.
What am I missing here? I'd like to use the scrollbar buttons as I'm used to: pressing them moves the thumb gradually in the appropriate direction, and not extremely like my case.
Answer by luismasuelli · Aug 05, 2019 at 05:17 PM
Found it: Scrollbars don't go to extremes. In my examples, they went because the scrolling size was less than 10 on either direction. By default scrollbars move by 10 when the buttons are pressed (Unity 2017.3, default skin).
Your answer
![](https://koobas.hobune.stream/wayback/20220612205710im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
hot t o control a character using scroll bar in unity 3d 0 Answers
Scrollview not showing scroll bar and not scrolling 1 Answer
Scroll rect starting in the middle 3 Answers
My scroll view always scrolls to the bottom automatically. 3 Answers
Scrollbar Automatically Resizing on Play, Stays Resized in Editor 0 Answers