Search Unity

Question Scrollview Handle Doesn't Reach Bottom

Discussion in 'UGUI & TextMesh Pro' started by Whitegrave, Mar 14, 2023.

  1. Whitegrave

    Whitegrave

    Joined:
    Apr 17, 2022
    Posts:
    44
    Anyone know why my scrollview handle doesn't line up with the borrom?

    The scroll area element is scaled to match the height of the parent, so I'm not sure what the issue is...

    Gif of the issue
    https://imgur.com/a/jYmY0v7

    Image of the bounds
    https://imgur.com/a/QA2TD6o

    I think it may be an issue with my handle settings, but I'm not familiar enough to know. Changing the "Bottom" field appears to do nothing, same results as 62 with 0
    https://imgur.com/a/ipa1UOk
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    Scrollbar and slider are two different components. Scrollbars change size of handle (in combination with scrollview based on ratio between visible and total size). Sliders have fixed handles.

    By setting high "bottom" value and "preserve aspect ratio" you are fighting against Unity. It might look like handle remained small but unity still assumes that it was able to successfully stretch the handle. That's why it doesn't reach bottom, if you didn't try to force the handle to look small everything would look correctly.

    In the intended way you need to use 9-sliced image for the handle and keep the config close to how it is by default when you create a new scrollbar. Top/bottom values can only be used to slightly tweak overlap/padding near the ends depending on the visuals of scrollbar components, it can also be used to configure minimum handle height.



    Some of your options are:
    * draw a scrollbar handle which can be stretched and restore the default setup

    If you really want a scrollview with a scrollbar that functions like a slider instead of scrollbar (don't recommend this unless you have appropriate programming skills):
    * don't use the builtin scrollbar integration. Create sliders and synchronize the state between scrollview and slider yourself. One directional sync is probably easy, but doing synchronizing the state in both directions is more tricky.
    * hacky solutions which try to overwrite or compensate scrollbar size change after scrollview changes it
    * modified version of scrollview or scrollbar which skips the scrollbar size change.
    * Look into alternative unity UI frameworks or extensions to UGUI