using System.Collections; using System.Collections.Generic; using UnityEngine; public class GPS : MonoBehaviour { public static GPS Instance { set; get; } public float latitude; //위도 public float longitude; //경도 // Start is called before the first frame update void Start() { Instance = this; DontDestroyOnLoad(gameObject); StartCoroutine(StartLocationService()); } private IEnumerator StartLocationService() { if (!Input.location.isEnabledByUser) { Debug.Log("GPS없다"); yield break; } Input.location.Start(); int maxWait = 20; while(Input.location.status==LocationServiceStatus.Initializing && maxWait > 0) { yield return new WaitForSeconds(1); maxWait--; } if(maxWait <= 0) { Debug.Log("없음"); yield break; } if(Input.location.status == LocationServiceStatus.Failed) { Debug.Log("Unable to determin device location"); yield break; } latitude = Input.location.lastData.latitude; longitude = Input.location.lastData.longitude; yield break; } // Update is called once per frame }