
300x300 크기의 이미지에서 정중앙에 클릭하면 150,150의 좌표를 가져옴(피벗이 0,0 기준)
왼쪽 최하단을 클릭하면 0,0의 좌표를 가져옴.
public void OnPointerClick(PointerEventData eventData)
{
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(GetComponent<RectTransform>(),
eventData.position, eventData.pressEventCamera, out Vector2 localCursor))
return;
Debug.Log("LocalCursor:" + localCursor);
}
출처: https://answers.unity.com/questions/892333/find-xy-cordinates-of-click-on-uiimage-new-gui-sys.html
'프로그래밍' 카테고리의 다른 글
C# XML 읽어오기 (0) | 2020.12.01 |
---|---|
C# DateTime 포맷 (0) | 2020.09.02 |
유니티 Microphone 녹음 시작-종료 지점 잘라서 녹음. (2) | 2020.08.28 |
C# 문자열로 변수이름 가져오기 (0) | 2020.04.19 |
C# 문자열을 int 리스트 / int 배열로 변환하기 (0) | 2020.02.28 |