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
- [Android] FPS does not match the targeted FPS when it is set with Application.targetFrameRate
- RenderPipelineManager.activeRenderPipelineTypeChanged does not detect changes when changing the Render Pipeline Asset outside of Play Mode
- The Scene View becomes gray and "NullReferenceException" errors are thrown when attaching the Unity Editor process to RenderDoc
- Memory usage rapidly rises when changing colors in the color wheel
- Physically Based Sky's Horizon and Zenith Tint Color Selection Bars don't have immediate access to color pickers
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;
}