public void Refresh() { mItems = new List <RectTransform>(); foreach (RectTransform item in mScrollView.content) { if (item.gameObject.activeSelf) { mItems.Add(item); } } if (mItems == null || mItems.Count == 0) { gameObject.SetActive(false); return; } else { WaitUtil.Start(0.03f, (a) => { mContentAnchoredXMin = -100000; mContentAnchoredXMax = 100000; for (int i = 0; i < mItems.Count; i++) { float itemLeftBorder = mItems[i].BotLeft().x; if (itemLeftBorder < mContentAnchoredXMax) { mContentAnchoredXMax = itemLeftBorder; } float rightBorderX = mItems[i].TopRight().x; float maxRightContentX = rightBorderX - mScrollView.viewport.rect.width; if (maxRightContentX > mContentAnchoredXMin) { mContentAnchoredXMin = maxRightContentX; } } mContentAnchoredXMax *= -1; mContentAnchoredXMin *= -1; mScrollView.StopMovement(); mScrollView.content.SetX(mContentAnchoredXMax); }); } #if USE_DOTWEEN DOTween.Kill(GetInstanceID()); #endif mIsDraging = false; mIsSnapping = false; }
public void MoveToItem(int pIndex, bool pImmediately) { if (pIndex < 0 || pIndex >= m_Items.Count) { return; } if (m_Validated) { SetFocusedIndex(pIndex); MoveToFocusedItem(pImmediately, m_SpringThreshold); } else { WaitUtil.Start(() => m_Validated, () => { SetFocusedIndex(pIndex); MoveToFocusedItem(pImmediately, m_SpringThreshold); }); } }