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
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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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;
}