Potential Bug: ScrollRect and Animations involving RectTransform.localScale

I’m having a problem with animating a ScrollRect GameObject. I have 2 simple animations - FadeIn and FadeOut - that smoothly change a GameObject’s RectTransform’s localScale from zero to one and vice versa. I have a parent object to which I apply the Fade animations, and that parent also holds a child GameObject that uses a scroll rect, image, and mask. Like any other scroll rect, the child also has children that makes up the content of the scroll view window.
When I apply the animations to the top most parent object, the scroll view window seems to scroll by itself a little bit. To clarify:

1914945--123550--before.png
A scroll rect window with a vertical slider bar before any animations have been played. The scroll view window is restricted so that it can only scroll vertically.

1914945--123551--after.png
The same window after a single FadeOut → FadeIn cycle.
Repeating the Fade cycle has the same effect; the scroll rect scrolls down by a little bit after each cycle.

Even stranger, the window only sometimes scrolls down*.* Other times it stays in the exact same position like you’d expect, which makes the problem all the more frustrating.

After a little bit more testing, it seems like it’s the FadeOut animation specifically that shifts the scroll rect down, but I still have no clue why it has this behavior. I’ve tried every kind of anchor possible, but nothing I change there seems to have any effect on the problem.

Have I stumbled upon a bug about ScrollRects and animations involving scales? or have I done something horribly wrong? Any help is greatly appreciated.

1 Like

Its 2017 and its still a bug in 2017.1 version :expressionless:

the bug is still there in 2019.x .the reason may be ScrollRect use GetWorldCorners and worldToLocalMatrix which relate to the scale .
in my case ,i use a tiny scale (such 0.001) instead of 0 ,it help me

2 Likes

hi, It’s still a bug in 2022.2 lts.
It’s exactly about 0 scale.
a tiny scale (such 0.001) instead of 0 is the best solution.

If you have other considerations, please try disabling the scroll rect component
or setting the scroll rect’s vertical and horizontal to false when the scale is 0, and do the opposite when it is not 0.

2 Likes

btw I hate unity. it’s basically a piece of shit.