위치2 [Unity] 마우스 위치를 UI 요소의 로컬 좌표로 변환하기 RectTransformUtility 클래스의 ScreenPointToLocalPointInRectangle 함수로 쉽게 구할 수 있다. 함수의 구조는 아래와 같다. public static bool ScreenPointToLocalPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector2 localPoint) Image를 Canvas(1600x900)에 생성한 후, 아래의 코드를 적용하였다. using UnityEngine; public class RTUtil : MonoBehaviour { public RectTransform rt; private void Update() { if (RectTransformUtil.. 2023. 9. 28. [Unity] GPS 기능으로 위도와 경도 불러오기 유니티에서 제공하는 LocationService 클래스로 간단히 GPS 기능을 구현해보자. 이번 글에서는 사진은 없고, 소스 코드를 위주로 진행해보겠다. 일단, 전체 소스를 먼저 보도록 하자. using UnityEngine; using UnityEngine.Android; //네임스페이스 추가 public class GPSModule : MonoBehaviour { [Header("Setting")] public bool startGPSOnStart; //Start문에서 GPS를 실행할 것인지 여부 public float desiredAccuracyInMeters; //현재 위치로부터의 최대 오차를 지정하는 변수 (정확도) public float updateDistanceInMeters; //특정 거리.. 2023. 8. 20. 이전 1 다음