public void SnapToCell(FishDataObject targetProfile) { if (cellDict.TryGetValue(targetProfile, out var profileCell)) { _selectedCellIndex = profileCell.index; selectedProfileCell = profileCell; selectedCellCursorTransform.position = selectedProfileCell.rectTransform.position; float scroll = scrollRect.GetTargetScrollValue(selectedCellCursorTransform); scrollRect.verticalNormalizedPosition = scroll; } }
void Update() { // canvasScaler.scaleFactor = pixelPerfectCamera.pixelRatio; HandleInput(); if (_showTimer >= 0f) { _showTimer -= Time.deltaTime; if (_showTimer >= 0f) { ShowPhone(PhoneScreen.NewMatch); } } if (_animatingScroll) { _scrollAnimationT += Time.deltaTime / scrollAnimationTime; scrollRect.verticalNormalizedPosition = Mathf.Lerp(_scrollStart, _scrollTarget, scrollCurve.Evaluate(_scrollAnimationT)); if (_scrollAnimationT >= 1f) { _animatingScroll = false; } } // update selected cell stuff selectedProfileCell = cellList[_selectedCellIndex]; Vector3 targetPos = selectedProfileCell.rectTransform.position; selectedCellCursorTransform.position = targetPos; float scroll = scrollRect.GetTargetScrollValue(selectedCellCursorTransform); scrollRect.verticalNormalizedPosition = MathUtil.Damp( scrollRect.verticalNormalizedPosition, scroll, scrollDamping, Time.deltaTime ); // update profile arrows if (phoneScreen == PhoneScreen.Profile) { if (blurbTMP.rectTransform.sizeDelta.y > profileScrollViewTransform.sizeDelta.y) { if (profileBlurbScrollRect.verticalNormalizedPosition >= 1f - 0.01f) { profileUpArrow.enabled = false; } else { profileUpArrow.enabled = true; } if (profileBlurbScrollRect.verticalNormalizedPosition <= 0f + 0.01) { profileDownArrow.enabled = false; } else { profileDownArrow.enabled = true; } } else { profileDownArrow.enabled = false; profileUpArrow.enabled = false; } } }