Canvas에 들어가는 UI 오브젝트들의 좌표를 정하려고 할 때
RectTransform에 접근하고 싶을 때가 있다.
일반적인
Object.GetComponent().position은 원하는 값으로 위치를 지정할 수 없다.
아래와 같이
Object.GetComponent().anchoredPosition = new Vector2(x, y);
anchoredPosition을 이용하면 정확한 값을 지정할 수 있다.
'Unity > Tip' 카테고리의 다른 글
Unity - 그림자가 안보일 때 (0) | 2020.04.07 |
---|---|
Unity - StackOverflowException: The requested operation caused a stack overflow (0) | 2020.04.02 |
Unity - 문자열 개행, Enter, 줄바꿈 (0) | 2020.03.31 |
Unity - 실시간 FPS 출력 (0) | 2020.03.27 |
Unity - Hierarchy에서 안보이는 GameObject 표시하기 (0) | 2020.03.20 |