1
NGUI 3 Support / UICenterOnChild.CenterOn which does not go over the scroll limit
« on: May 19, 2015, 05:52:25 AM »
Hi
I am using NGUI3.8.2
I use UIScrollView.
I use UICenterOnChild.CenterOn.
UICenterOnChild.CenterOn ignores the scroll limit.
I remodeled CenterOn not to go over the scroll limit.
Before
After
How is this?
I am using NGUI3.8.2
I use UIScrollView.
I use UICenterOnChild.CenterOn.
UICenterOnChild.CenterOn ignores the scroll limit.
I remodeled CenterOn not to go over the scroll limit.
Before
- // Spring the panel to this calculated position
- #if UNITY_EDITOR
- if (!Application.isPlaying)
- {
- panelTrans.localPosition = panelTrans.localPosition - localOffset;
- Vector4 co = mScrollView.panel.clipOffset;
- co.x += localOffset.x;
- co.y += localOffset.y;
- mScrollView.panel.clipOffset = co;
- }
- else
- #endif
- {
- SpringPanel.Begin(mScrollView.panel.cachedGameObject,
- panelTrans.localPosition - localOffset, springStrength).onFinished = onFinished;
- }
After
- // Spring the panel to this calculated position
- #if UNITY_EDITOR
- if (!Application.isPlaying)
- {
- panelTrans.localPosition = panelTrans.localPosition - localOffset;
- Vector4 co = mScrollView.panel.clipOffset;
- co.x += localOffset.x;
- co.y += localOffset.y;
- mScrollView.panel.clipOffset = co;
- }
- else
- #endif
- {
- // Change Begin
- var move = panelTrans.localPosition - panelTrans.localPosition - localOffset;
- mScrollView.MoveRelative(move);
- var ofs = mScrollView.panel.CalculateConstrainOffset(mScrollView.bounds.min,mScrollView.bounds.max);
- var targetPos = ofs + panelTrans.localPosition;
- mScrollView.MoveRelative(-move);
- SpringPanel.Begin(mScrollView.panel.cachedGameObject,targetPos, springStrength).onFinished = onFinished;
- // Change End
- }
How is this?