private IEnumerator SnapCoroutine(string tierId = null) { while (Math.Abs(scrollRect.velocity.y) > 1024) { yield return(null); } yield return(null); var tierCards = scrollRect.GetComponentsInChildren <TierCard>().ToList(); if (tierCards.Count <= 1) { snapCoroutine = null; yield break; } try { TierCard toTierCard; if (tierId == null) { toTierCard = tierCards .FindAll(it => !it.Tier.isScrollRectFix) .MinBy(it => Math.Abs(it.rectTransform.GetScreenSpaceCenter(it.canvas).y - ScreenCenter.y)); scrollRect.SrollToCell(toTierCard.Index, 1024); } else { toTierCard = tierCards.FirstOrDefault(it => it.Tier.Id == tierId); if (toTierCard == null) { toTierCard = tierCards[0]; } scrollRect.SrollToCell(toTierCard.Index, 1024); } selectedTierCard = toTierCard; OnTierSelected(toTierCard.Tier); } catch (Exception e) { Debug.LogWarning(e); tierCards.FindAll(it => !it.Tier.isScrollRectFix).ForEach(it => print(Math.Abs(it.rectTransform.GetScreenSpaceCenter(it.canvas).y - ScreenCenter.y))); } snapCoroutine = null; }