본문 바로가기

Unity/API - RectTransform4

RectTransform 이해하기: Pan & Pinch Zoom 구현 Pan & Pinch Zoom 구현 터치한 영역을 기준으로 확대/축소 되는 '핀치 줌'과 두 손가락 '패닝'을 RectTransform의 scale과 anchoredPosition 속성으로 구현해보자. 일단 튜토리얼 문서에서 Mobile Input을 간단히 알아보자. Getting Mobile Input - Unity Learn Modern mobile devices have screens that can receive accurate multitouch inputs from the user and from multiple device sensors. In this tutorial you will learn how to get inputs from the touchscreen and acceleromet.. 2020. 8. 18.
RectTrnasform 이해하기: Canvas - ScreenSpace Canvas - ScreenSpace ScreenSpace는 WorldSpace랑 다르게 Screen 공간에서 고정인 좌표이다. 모바일 디스플레이나 모니터 디스플레이에 붙어서 떨어지지 않는 좌표이다. 언제나 좌측 하단 (0,0), 우측 상단 (디스플레이 해상도)의 좌표 범위를 벗어나지 않는다. ScreenSpace - Camera 카메라가 WorldSpace 좌표계 (x, y, z)의 (-1, -1, 0)에 위치했다. Canvas의 RenderMode가 ScreenSpace - Camera로 설정되면 일단 해당 Canvas의 width와 height은 디스플레이(Screen)를 가득 채운다. 그리고 Canvas의 피벗에 상관없이 정중앙은 카메라의 가운데에 위치한다. Scale은 임의로 조정할 수 없다. .. 2020. 8. 14.
RectTransform 이해하기: Canvas - WorldSpace Canvas - WorldSpace RenderMode 중 WorldSpace는 Canvas가 따르는 좌표를 WorldSpace로 설정하는 것이다. width와 height이 (4,4)인 캔버스를 예로 들어보자. 이 캔버스는 pivot이 가운데 있다. 이 pivot의 worldPosition과 localPosition의 값은? canvas.position (worldposition) scale이 x1이기 때문에 WorldSpace와 Canvas의 좌표가 동일하다. 그래서 worldPosition은 칸의 갯수를 통해 쉽게 파악할 수 있다. 따라서 canvas.position = (2,2) 이다. canvas.localPosition 이 캔버스의 상위 개체는 없다. 사실 상 WorldSpace 자체가 상위 .. 2020. 8. 14.
RectTransform 이해하기: rect, scale, anchoredPosition vs localPosition RectTransform WorldSpace 좌표계로 가정한다. RectTransform canvas 값 panel 값 .position (WorldSpace) ㆍWorldSpace 상의 피벗 위치 (3, 2) ㆍWorldSpace 상의 피벗 위치 (5, 4) .position (ScreenSpace) ㆍScreenSpace 상의 피벗 위치 cf. 해상도 1920x1080 가정 (960,540) ㆍScreenSpace 상의 피벗 위치 cf. 해상도 1920x1080 가정 (1600,1080) .rect.position ㆍ피벗으로부터 왼쪽 하단 모서리까지의 거리 ㆍ(0,0) - 피벗 위치 (-3, -2) ㆍ피벗으로부터 왼쪽 하단 모서리 까지의 거리 ㆍ(2,2) - 피벗 위치 (-3, -2) .anchore.. 2020. 8. 12.