From 68f67916d5ae5e8f77bd54ae64f84b5ccbd57b05 Mon Sep 17 00:00:00 2001 From: YogurSligh <745233178@qq.com> Date: Wed, 14 Jun 2017 12:33:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=97=B6=E5=8F=91=E7=8E=B0?= =?UTF-8?q?=E6=9C=89=E6=BB=91=E5=8A=A8=E6=96=B9=E9=9D=A2=E7=9A=84Bug?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来的逻辑在多行多列的情况下,可能最后一行会滑不进显示区域,我发现了这个问题并尝试修改了。原因在于计算包围盒大小的算法出了点问题。 --- Assets/Foundation/UIComponent/GridScroller.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Foundation/UIComponent/GridScroller.cs b/Assets/Foundation/UIComponent/GridScroller.cs index d532e31..4ecd139 100644 --- a/Assets/Foundation/UIComponent/GridScroller.cs +++ b/Assets/Foundation/UIComponent/GridScroller.cs @@ -157,11 +157,11 @@ private void InitTransform(Vector2? normalizedPosition = null) if (_moveType == Movement.Horizontal) { - _grid.GetComponent().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, ((_itemCount + 1) / _row) * ItemSize.x); + _grid.GetComponent().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.CeilToInt((float)_itemCount / _row) * ItemSize.x); } else { - _grid.GetComponent().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ((_itemCount + 1) / _col) * ItemSize.y); + _grid.GetComponent().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt((float)_itemCount / _col) * ItemSize.y); } _scroller.onValueChanged.AddListener(OnValueChanged); _scroller.normalizedPosition = (normalizedPosition.HasValue) ? normalizedPosition.Value : new Vector2(0, 1);