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
- An image bleeds out of the borders of a Mask when the project is opened with the iOS Build Support module
- Shadows do not appear on the Material with a custom shader which uses screen space shadow map in HDRP when Ray Traced Shadows are enabled
- An emoji is not shown in the UI Builder Viewport and the Game view when it is placed in the Labels text attribute and Usage Hints is set to Dynamic Color
- The Sprite Renderers are looking for Secondary Textures from the wrong page within the Sprite Atlas when the Sprite Atlas has a large amount of textures for packing
- [URP] Invalid update of shader stripping settings
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;
}