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
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
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;
}