본문 바로가기
개발/Unity

Unity) RectTransform 비율로 처리하기

by 테샤르 2023. 12. 12.

RectTransform 비율로 처리하기

 

Unity RectTransform을 비율로 처리하는 방법에 대해서 간략하게 포스팅한다.

<Hierarchy>

 

반응형

 

흰색 배경의 오브젝트에 0.45%의 빨간색 영역을 차지하려면 컴포넌트를 다음과 같이 처리하면 된다.

 

< Component >

 

 

결론적으로는RectTransform 의 Size Delta/   Anchors / Pivot 의 설정으로 다음과 같이 처리가 된 것이다.

 

Anchors Max : 0 ~ 1 사이의 값이고 여기의 0.45 < 이 값이 전체를 기준으로 비율(45%)를 나타내고 

이때 중요한 Size Delta 값은 0,0,0,0 이여야 한다.

Pivot 값은 어디를 기준으로 중심점을 처리할 것이야 하는 수치 값이다.

 

Unity discussions. Position UI element as Percentage of parent object : [링크]

 

Position UI elements as percentage of parent object

Yes, there are other ways to achieve what you need without scaling the text. One common approach is to use the RectTransform component to position and size UI elements as a percentage of their parent object. Here’s a step-by-step guide on how you can do

discussions.unity.com

 

 

★☆☆☆☆

 

반응형

댓글