겨울팥죽 여름빙수
Unity, ScrollRect verticalNormalizedPosition 조절
게임을 만들자/Unity 2023. 11. 7. 12:38

private void ScrollMoveToTargetObject(Vector2 _targetPosition) { scrollRect.verticalNormalizedPosition = (_targetPosition.y - scrollRect.GetComponent().rect.height*0.5f) /(scrollRect.content.rect.height - scrollRect.GetComponent().rect.height); } 위 코드는 ScrollRect/Content내의 타겟 Object로 이동하는 코드이다. 새로 스크롤이고, 해당 타겟이 가운데로 오게끔한다. 공식은 다음과 같다. verticalNormalizedPosition = (타겟의 위치 - ScrollRect 크기*0.5)/(Co..