2019/09 7

[Unity] 클릭 혹은 터치한 곳의 오브젝트 정보 얻어내기

어떤 오브젝트를 터치했는지 알아내서 처리하는 코드 void Update() { if (Input.GetMouseButton(0)) { Vector2 touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D hitInformation = Physics2D.Raycast(touchPos, Camera.main.transform.forward); if (hitInformation.collider != null) { //We should have hit something with a 2D Physics collider! GameObject touchedObject = hitInformation.transform.gameObject;..

카테고리 없음 2019.09.28

[Unity] Canvas 상에서의 position 에 대해

Unity 에서 UI 요소를 삽입하면 Canvas 폴더가 생기고, 그 아래에 있는 객체들은 기존의 좌표체계와 달라지는 것을 볼 수 있다. (RectTransform 은 Transform 을 상속받은 클래스라 한다.) 어쨌든, RectTransform 속성을 지닌 객체의 포지션에 대해 이해한 것만을 적어 본다. 직관적으로 쉽게 이해하기 위해 원점 좌표를 주면 어디에 위치하는지 테스트 해보았다. 테스트를 위해 Panel 을 생성하고 그 안에 Image 객체를 넣었다. Panel 사이즈는 1920x1080 전체화면으로 했고, Image 는 100x100 이다. (단위는 Pixel) Panel 의 인스펙터 RectTransform (1920x1080 스크린 전체를 차지한다.) Pos X : 0, Pos Y : ..

Unity 2019.09.27

[Unity] INSTALL_FAILED_NO_MATCHING_ABIS 안드로이드 에뮬레이터에 apk 설치가 안될 때

** 문제점 ** 안드로이드 에뮬레이터를 띄운 후 Build and Run 을 하자 이런 메시지를 만났다. 유니티에서의 에러 메시지: D:/AndroidSDK\platform-tools\adb.exe -s "emulator-5554" install -r "D:\UnityProjects\MyApp.apk 커맨드 라인에서 adb 로 설치해 보았다. adb install MyApp.apk adb: failed to install MyApp.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113] ** 해결방법 ** 유니티 안드로이드 Player Settings 에서 x86 을 추가 하면 해결 됨.

Unity 2019.09.23