I’m trying to flick my ScrollRect manually with script (For example - buttons on sides of horizontal scroll rect, that would flick the scrolling content automatically by some value)
myScrollRect.velocity = Vector2.right * 1000f;
This works, but only when I flick manually and click those buttons before the content settles. I couldn’t find any myScrollRect.AddForce alternative. Is that possible?
Many thanks.
I’m going to answer my own question.
I think I stumbled on Unity Bug because setting ScrollRect.velocity via script works normally unless it is called when ScrollRect.normalizedPosition.x or y is smaller then 0 or greater than 1. This happens quite a lot when scroll rect settles on edges.
I added this to my script:
scrollRect.horizontalNormalizedPosition = Mathf.Clamp(scrollRect.horizontalNormalizedPosition, 0.0001f, 0.9999f); //Clamping between 0 and 1 just didn't do...
scrollRect.velocity = Vector2.right * 1000;