게임 개발/Unity

Rect Transform 잠깐 메모

로켓곰군 2020. 2. 9. 23:02

참고 블로그 : https://wergia.tistory.com/184

 

[Unity3D] UI 비법서 (4) - UI 개발자라면 제발 Rect Transform 애용합시다!

UI 비법서 (4) - UI 개발자라면 제발 Rect Transform 애용합시다! 작성 기준 버전 :: 2019.1.4f1 유니티 개발을 처음으로 공부하는 개발자들은 기본적으로 게임 오브젝트의 위치를 이동시키는 코드를 작성하려고..

wergia.tistory.com

 

 

UI 컴포넌트 간 위치 지정시 일반 Transform 좌표가 아닌 Rect Transform 좌표를 사용할것.

 

Rect의 기준점으로 사용될수 있는건 4가지 데이터가 있는데, Up, left, right, bottom 4가지.

 

Up / bottom은 y축 값, left, right는 x축 값이며,

 

up, right 는 offsetMax, bottom, left는 offsetMin값이다

 

즉, rect transform의 bottom이 필요한 경우

 

var rect = (rect 정보를 가져올 오브젝트).GetCompo.GetComponent();

foo(rect.offsetMin.y);

var rect = (rect 정보를 가져올 오브젝트).GetCompo.GetComponent();
foo(rect.offsetMin.y);

 

식으로 획득이 가능하다.