/// <summary> /// 获取地理位置 /// </summary> /// <returns></returns> private IEnumerator GetLocation() { m_location = "/"; // First, check if user has location service enabled if (!Input.location.isEnabledByUser) { m_geoState = GeoState.Enable; yield break; } // Start service before querying location Input.location.Start(); if (Input.location.status == LocationServiceStatus.Initializing) { m_geoState = GeoState.Opening; } // Connection has failed if (Input.location.status == LocationServiceStatus.Failed) { m_geoState = GeoState.OpenError; yield break; } else { m_location = Input.location.lastData.latitude + "/" + Input.location.lastData.longitude; m_geoState = GeoState.Success; } // Stop service if there is no need to query location updates continuously Input.location.Stop(); }
private void SetState(GeoState newState) { state = newState; }
private void Awake() { m_geoState = GeoState.Init; m_isGetLocationValue = false; StartCoroutine(GetLocation()); }