// Update is called once per frame void Update() { if (this.enableTracking) { if (Time.time - this.lastLocationCheck > kLocationCheckInterval) { this.lastLocationCheck = Time.time; this.locationCheckCount++; LocationServiceStatus status = Input.location.status; #if UNITY_EDITOR if (this.locationCheckCount > 2) { status = LocationServiceStatus.Running; } #endif string textLabelText = "Status: " + status.ToString() + " c:" + this.locationCheckCount; if (status == LocationServiceStatus.Stopped) { Input.location.Start(1, 1); } else if (status == LocationServiceStatus.Running) { LocationInfo locInfo = Input.location.lastData; textLabelText += "\nAccuracy: " + locInfo.horizontalAccuracy.ToString("F1") + " x " + locInfo.verticalAccuracy.ToString("F1"); this.storedLocationInfos.Add(locInfo); } for (int i = 0; i < 5; i++) { int index = this.storedLocationInfos.Count - i - 1; if (index > 0) { LocationInfo locInfo = this.storedLocationInfos[i]; textLabelText += "\ni: " + index + " {" + locInfo.latitude.ToString("F3") + "," + locInfo.longitude.ToString("F3") + "} acc: " + locInfo.horizontalAccuracy.ToString("F1") + " x " + locInfo.verticalAccuracy.ToString("F1"); } } this.outputText.text = textLabelText; } } }
// Update is called once per frame void Update() { if (Application.platform == RuntimePlatform.Android) { /* * double latitude = locationManager.GetLatitude(); * double longitude = locationManager.GetLongitude(); * * if (latitude != 0 && longitude != 0) * { * transform.position = beaconManager.GetPosition(latitude, longitude); * }*/ LocationServiceStatus status = iPhoneSettings.locationServiceStatus; if (status != LocationServiceStatus.Running) { if (prevStatus != status) { Debug.Log("Location Status: " + status.ToString()); prevStatus = status; } } else { LocationInfo loc = iPhoneInput.lastLocation; if (prevLocation.latitude != loc.longitude || prevLocation.longitude != loc.longitude) { Debug.Log("Location: " + loc.latitude.ToString() + ", " + loc.longitude.ToString()); prevLocation = loc; } Vector3 position = beaconManager.GetPosition(loc.latitude, loc.longitude); transform.position = new Vector3(position.x, transform.position.y, position.z); } } }
public override void Update() { /* * double latitude = locationManager.GetLatitude(); * double longitude = locationManager.GetLongitude(); * * if (latitude != 0 && longitude != 0) * { * transform.position = beaconManager.GetPosition(latitude, longitude); * }*/ LocationServiceStatus status = iPhoneSettings.locationServiceStatus; if (status != LocationServiceStatus.Running) { if (prevStatus != status) { Debug.Log("Location Status: " + status.ToString()); prevStatus = status; } absolutePosition = null; } else { LocationInfo loc = iPhoneInput.lastLocation; if (prevLocation.latitude != loc.longitude || prevLocation.longitude != loc.longitude) { Debug.Log("Location: " + loc.latitude.ToString() + ", " + loc.longitude.ToString()); prevLocation = loc; } absolutePosition = beaconManager.GetPosition(loc.latitude, loc.longitude); absolutePosition = new Vector3(absolutePosition.Value.x, playerManager.transform.position.y, absolutePosition.Value.z); } base.Update(); }
private void SetDebugInfos(LocationServiceStatus locStatus, LocationInfo locInfo) { SetDebugInfos(locStatus.ToString(), locInfo.latitude.ToString(CultureInfo.InvariantCulture), locInfo.longitude.ToString(CultureInfo.InvariantCulture), locInfo.altitude.ToString(CultureInfo.InvariantCulture), UnixTimeStampToDateTime(locInfo.timestamp).ToString(CultureInfo.InvariantCulture), locInfo.horizontalAccuracy.ToString(CultureInfo.InvariantCulture), locInfo.verticalAccuracy.ToString(CultureInfo.InvariantCulture)); }
private void SetDebugInfos(LocationServiceStatus locStatus, LocationInfo locInfo) { SetDebugInfos(locStatus.ToString(), locInfo.latitude.ToString(CultureInfo.InvariantCulture), locInfo.longitude.ToString(CultureInfo.InvariantCulture), locInfo.altitude.ToString(CultureInfo.InvariantCulture), UnixTimeStampToDateTime(locInfo.timestamp).ToString(CultureInfo.InvariantCulture), locInfo.horizontalAccuracy.ToString(CultureInfo.InvariantCulture), locInfo.verticalAccuracy.ToString(CultureInfo.InvariantCulture)); }