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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Simple ScrollRect Tools: ScrollRectTweener and ScrollRectLinker

Discussion in 'UGUI & TextMesh Pro' started by Democide, Aug 26, 2015.

  1. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    Crossposted from the Sharkbomb Studios blog:

    Working on Nowhere Prophet I built two quick tools for the ScrollRect. I wanted to briefly post them here so maybe someone else can get some use out of them.

    One called the ScrollRectTweener can take control over a ScrollRect and smoothly scroll it to a given normalized target position. If the player moves the view while the tweener is acting, then it aborts it’s movement, but you have the option to lock out the player drag when it is working.

    The second is the ScrollRectLinker. This component can be put on one scrollRect to link its normalized position to the normalized position of another scrollRect. That way simple parallax scrolling can be quickly set up.

     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    Wow, interesting as ever. Is it ok to add these to the UI Extensions project?
    Now that I'm back of hols, I'm sparing some time to update it.
     
  3. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    sure. Credit me, as usual ;)
     
    SimonDarksideJ likes this.
  4. saarwii

    saarwii

    Joined:
    Mar 7, 2014
    Posts:
    24
    This is exactly what i need. I do get some jittery movement from the scroll rect. I am passing the touch.deltaposition in to it?Is there another value i can use from the touch that is more suited for this to get a smoother motion?
     
  5. saarwii

    saarwii

    Joined:
    Mar 7, 2014
    Posts:
    24
    I figured it out myself. I multiply the deltaposition.x value with a really low value, 0.1 in my case. And the duration value i also use a fairly low value. It works for prototyping purposes, ideally I would have to write something that delivered the same touch value, regardless of what touch device is being used
     
  6. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    Hm. I don't quite follow.
     
  7. alexjolig

    alexjolig

    Joined:
    Jul 26, 2016
    Posts:
    3
    Thank you! It works perfect! Saved me a huge lots of time!
     
  8. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    You're welcome!