Search Issue Tracker
Fixed in 5.4.0
Votes
6
Found in
Issue ID
643604
Regression
No
Setting ScrollRect's normalized position does not work if you do it just after setting size of the content
To reproduce this bug:
1. Import the attached package
2. Open 'scene'
3. There is 'ScrollView' and 'Panel' as its Content
3. Press play
4. 20 Buttons are generated as children of the Panel
5. Notice in the 'ScrollRectScript' that after Buttons are generated, ScrollRect.NormalizedPosition is set to (0,1) but the panel is still centered
6. Press Space. It sets NormalizedPosition to (0,1) again, and now it works fine
7. Stop the scene and select Panel ( Canvas -> Scroll View -> Panel)
8. Change Content Size Fitter's Vertical Fit to Unconstrained
9. Change Rect Transform's height to around 5000(So all the buttons would fit in.
10. Play again and NormalizedPosition is now set correctly
It seems that is does not work correctly only when you try to set it just after the Button are Instantiated and Panel's size is determined
Comments (2)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Documentation link icons' are not aligned in he "Recommendation" tab
- "Game Specifications" section becomes blank, and users get "ArgumentException: Cannot unschedule unknown scheduled function" during the "Game Specification" selection when the "Multiplayer Center" window is docked
- Foldout arrow indent is misaligned in the Inspector when used in Custom Type
- [Android] The Player screen turns black when playing a video under certain conditions
- Search window icons at the bottom are cut off when Search window is resized vertically
dval
Mar 14, 2022 14:28
This still happens in Unity 2020.3.29f. I think the only "fix" is the workaround MOJTABA64 posted.
mojtaba64
Feb 09, 2015 22:54
Yeah, I have this problem too.
You can use this:
void focusOn(RectTransform x)
{
StartCoroutine(iFocusOn(x));
}
IEnumerator iFocusOn(float x)
{
yield return new WaitForEndOfFrame();
_scrollRect.horizontalNormalizedPosition = x;
}