Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Scroll Rect - Invert scroll direction of ScrollRect for mousewheel but not click-drag???

Discussion in 'UGUI & TextMesh Pro' started by mcurtiss, Jul 12, 2020.

  1. mcurtiss

    mcurtiss

    Joined:
    Nov 29, 2012
    Posts:
    26
    So I want very simple behavior for Scroll Rect - when you click and drag down, it should scroll down.

    The default behavior is the opposite: when you click and drag down, it scrolls up.

    Similarly, when you mouse-wheel down, the default behavior is to scroll up.

    I want to invert this behavior. It seems the way to do this is to set the 'scroll sensitivity' variable on the Scroll Rect to a negative number. When you do this, it does indeed invert the behavior for the mouse-wheel, but it does not invert it for click-drag functionality. With a value of '-10', click-dragging downards will still scroll up, whereas mouse-wheelling down behavior is successfully inverted; it will scroll downward.

    Looking at the Scroll Rect API, it does not appear there is any other way to invert the click-drag behavior.

    This doesn't seem to be a bug as I've checked a previous versions of unity and it works this way (2019.3).So how do I go about inverting click-drag scroll direction? Feels like there should be a simple solution and I'm missing it.

    I can find the scroll rect source on github and add the inversion, but that seems like it should be unnecessary.
     
    Last edited: Jul 12, 2020
    Adam_Streck likes this.
  2. Adam_Streck

    Adam_Streck

    Joined:
    Jul 31, 2013
    Posts:
    26
    Same issue here in 2019.4.10f1
     
  3. Adam_Streck

    Adam_Streck

    Joined:
    Jul 31, 2013
    Posts:
    26
    Hey, found the issue:

    If the scrollbar is over the viewport, the scrollbar must be BELOW the Viewport in the hierarchy.

    If it above it is still visible, but the raycast target no longer registers, so you think you're dragging the scrollbar, but you're in fact dragging the viewport and it drags the other way than the scrollbar.

    Right:
    upload_2020-9-30_12-0-46.png

    Wrong:
    upload_2020-9-30_12-0-59.png
     
  4. MervayB

    MervayB

    Joined:
    Jan 18, 2020
    Posts:
    5
    Thanks, you just saved me!
     
  5. thelocationlabdeveloper

    thelocationlabdeveloper

    Joined:
    Sep 8, 2020
    Posts:
    14
    thank buddy this is help full