IEnumerator LocationUpdate() { int retryCounter = 20; if (locationService.isEnabledByUser) { isLocationUpdating = true; locationService.Start(); while (locationService.status == LocationServiceStatus.Initializing && retryCounter > 0) { retryCounter--; yield return(new WaitForSeconds(1.0f)); } if (locationService.status == LocationServiceStatus.Running) { locationCoordination.SetCoordination(locationService.lastData.longitude, locationService.lastData.latitude); //metricsCoordination.ConvertLongAndLetiToMetrics(); distanceCalculator.DistanceCalculation(); } else { Debug.Log("failed Location Service initiation"); } //locationService.Stop(); isLocationUpdating = false; } yield return(null); }
// Use this for initialization void Start() { locationService = Input.location; locationCoordination = ScriptableObject.CreateInstance <LocationCoordination>(); distanceCalculator = gameObject.GetComponent <DistanceCalculator>(); googleMapDrawer = GameObject.FindGameObjectWithTag("MapDrawer").GetComponent <GoogleMapDrawer>(); spotManager = GameObject.FindGameObjectWithTag("SpotManager").GetComponent <SpotManager>(); googleMapDrawer.Calculator = locationCoordination; //ロケーションサービスが無効、かつユーザーが許可しているなら //ロケーションサービスを有効化 switch (Application.platform) { case RuntimePlatform.Android: case RuntimePlatform.IPhonePlayer: isMobilePlatform = true; break; } if (isMobilePlatform) { switch (locationService.status) { case LocationServiceStatus.Stopped: LocationUpdate(); break; default: break; } } else { locationCoordination.SetCoordination(initlong, initlat); } }