Search Unity

How to use GUI.VerticalScrollbar?

Discussion in 'Immediate Mode GUI (IMGUI)' started by eses, May 10, 2021.

  1. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi.

    I have tried to implement a simple custom list view so I would be able to show items without slowdown. Seems like Unity's scroll view created with EditorGUILayout.BeginScrollView/EndScrollView is pretty slow with 1000-2000 items.

    So I created my own view, first with buttons, but then I decided to try a vertical scroll bar for changing which part of my list is shown.

    Questions (about GUI.VerticalScrollbar):
    1. Is there any information somewhere about "size" parameter? I couldn't find anything yet. Docs only say "How much can we see".

    2. Seems like GUI.VerticalScrollBar likes absolute values, instead of fractional value (0-1), but that isn't my problem. If I pull the thumb/handle all the way down, value shows something less than bottomValue when the bottom edge of thumb bar touches the bottom edge of elevator bar area. It seems like it is a halfway value between the top and the bottom end of the thumb bar? Is there any documentation about this?

    3. Is there any way to change the amount up/down arrows move the view position? Now it seems like those have a step of 10 by default?
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Well I sort of figured it out.

    I think I can live with it, math isn't correct. There is some small amount of inaccuracy.

    When I scroll to the end of list, elevator thumb reaches bottom position slightly before the content.

    Actually it didn't bother me too much that originally the content scrolled way past the last line, resulting in nearly empty list view at the end position. List also scrolls one line at time, but it is fast as it only renders visible rows, it doesn't matter if there is 10 or 10000 lines of content.

    20210511_vertical_list.gif

    ...but I still wish I knew how this thing works exactly.
     
    Last edited: May 11, 2021