Search Unity

Make scrolling move faster in scrollRect?

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Bitfabrikken, Dec 19, 2015.

  1. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    Currently when you scroll something in a scrollRect, by using the mouse, touch etc., it's on a 1:1 basis.
    Move the mouse 100 pixels, and the content is scrolled 100 pixels.

    Is there a way to e.g. double this?
    So when moving the mouse (or dragging when using touch) 100 pixels, the content is scrolled 200 pixels.
    I guess I'm looking for a multiplier or something, but I don't know where to find it, or how to achieve it.
    Hope someone can help me :)
     
  2. jtsmith1287

    jtsmith1287

    Joined:
    Aug 3, 2014
    Posts:
    779
    Isn't there a sensitivity in the scrollview prefab? Have you tried playing with that?
     
  3. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    There is, but it's got to do with sensitivity towards the start of scrolling, not scrolling speed itself.
     
  4. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Pretty sure scrolling speed is based on the User's Scroll wheel setup via the machine's system settings.
     
  5. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    And on mobile? I want to be able to increase scroll speed on mobile, when touch-dragging to scroll.
     
  6. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Mobile is based on momentum, how quick the user flicks their finger.
     
  7. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    I'm pretty sure it's not. It seems to be 1:1 when I make something with scrollRect. Both in editor and live on devices.
     
  8. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    You could look into this.
     
  9. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Pretty sure it is.
     
  10. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    As I said above, scrollSensitivity has to do with sensitivity towards the start of scrolling, not scrolling speed itself. The manual is poorly worded.
     
  11. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    There is a deceleration. Try decreasing that?
     
  12. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    Again it's scrolling speed when scrolling I'm after (when touching and scrolling) - not deceleration, which occurs after you've scrolled (released touch). There's no deceleration occuring when you're actively scrolling obviously.
     
  13. jtsmith1287

    jtsmith1287

    Joined:
    Aug 3, 2014
    Posts:
    779
    So, normally when you scroll with your finger the user is "dragging" the window in the direction they're moving their finger. It gives the illusion that they're physically dragging the object. I implemented my own drag feature quite easily but my first iteration had the speed too high. Every pixel I moved my finger the object underneath moved 2. It was a really, really awkward feeling.

    Basically, I don't think you want what you're asking for. Every app I've ever used, game or not, you just flicked the contents up really fast and let is scroll for a long time if you wanted to scroll quickly. Reduce the deceleration time so people can flick, call it good. :) No one will think, "Golly I wish this was faster" except you, most likely.
     
  14. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    5,004
    Sorry to necro-post this thread, but I made a quick patch to the Unity ScrollRect to get faster-than-finger scrolling. It is AWESOME on mobile.

    It is EXTREMELY useful when you have large images of content, and yet you want to quickly go through them without having to whip them along "ballistically."

    If you go to this file: https://bitbucket.org/Unity-Technol...llRect.cs?at=5.2&fileviewer=file-view-default

    Then you can download ScrollRect.cs and modify it to make your own that supports higher-than-finger scroll rates. Once you use it, every other scroll rate with 1:1 finger mapping (i.e., normal Apple / Android scroll rates) just feels glacially slow.

    I recommend renaming the class and filename, such as "MyScrollRect.cs" and of course the internal MonoBehavior itself.

    The first patch is about line 63 in the property declarations, add these two lines:

    Code (csharp):
    1. [SerializeField]
    2. private float m_ScrollFactor = 1.0f;
    3. public float scrollFactor { get { return m_ScrollFactor; } set { m_ScrollFactor = value; } }
    4.  
    The second patch is inside the OnDrag() method, approximately line 348 in the original file, AFTER the pointerDelta is calculated, but before it is used to calculate position:

    Code (csharp):
    1. var pointerDelta = localCursor - m_PointerStartLocalCursor;
    2. pointerDelta *= m_ScrollFactor;    // this line is new!
    3. Vector2 position = m_ContentStartPosition + pointerDelta;
    Now you're done. Use this newly-named ScrollRect anywhere you would use the Unity one and you can have faster-than-finger (or faster-than-mouse drag) scrolling. It's awesome if I do say so myself!
     
    SkylinR, yyylny, vuthang and 12 others like this.
  15. Trungdv

    Trungdv

    Joined:
    Dec 1, 2012
    Posts:
    17
    @Kurt-Dekker Thank you very much! You saved my day, sir!
     
    Kurt-Dekker likes this.
  16. ostatnicky

    ostatnicky

    Joined:
    Jan 23, 2017
    Posts:
    1
    Kurt-Dekker likes this.
  17. kidzooly

    kidzooly

    Joined:
    Jan 23, 2016
    Posts:
    7
  18. vuthang

    vuthang

    Joined:
    Mar 7, 2017
    Posts:
    6

    Attached Files:

    Kurt-Dekker likes this.
  19. SkylinR

    SkylinR

    Joined:
    Sep 4, 2015
    Posts:
    5
    Kurt-Dekker likes this.
  20. YuHeLong

    YuHeLong

    Joined:
    Apr 17, 2015
    Posts:
    10
    After I put in the modified script in my assets folder, How do I add the script to the gameobject, it says script not found?
     
  21. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    5,004
    Make sure it a) compiles without any errors, b) is named uniquely, and c) has the same exact filename as the class name, including capitalization.
     
  22. KarolRG

    KarolRG

    Joined:
    Jul 9, 2019
    Posts:
    2
    I've created also some scripts which improve speed of scrolling but in a little bit different way. Previous ones was making faster entire dragging and inertia scrolling. I wanted only that inertia to be faster (moment when you stop dragging screen and it's scrolling by "force" after swipe).
    It's simple to Use:
    - Add ScrollRectFasterEditor.cs to "Assets/Editor". If you don't have this catalogue then create one.
    - Add ScrollRectFaster.cs anywhere in your Asset folder.
    - Create ScrollView GameObject
    - Change ScrollRect script to ScrollRectFaster script (just delete old one and drag on GO to add new script)
    - Finally drag all required thins to ScrollRectFaster like Content, Viewport etc.
    And that's all.

    To increase speed of scrolling edit value Inertia Velocity Multiplier (Like on screenshot)

    Important: As i wrote it's working with inertia so checkbox Inertia needs to be checked to display that option to increase scroll speed.
     

    Attached Files:

unityunity