- Home /
Unity3D Android 8.1 LocationServiceStatus GPS
Hello everyone :)
At the moment I am trying to retrieve the GPS location in a Unity3D (2018.2.14f1)/Android project. Input.location.status seems to stick with LocationServiceStatus.Initializing. I looked up different forums and tried to set the GPS mode on my smartphone (Xiaomi A2) to High Accuracy. I tested different configurations in the Unity Studio but nothing seems to work.
What could be the problem? :)
Thank you very much in advance
while (true)
{
Input.location.Start(1f, .1f);
if (!Input.location.isEnabledByUser)
yield break;
// Start service before querying location
// Wait until service initializes
int maxWait = 10;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
{
yield return new WaitForSeconds(1);
maxWait--;
}
if (maxWait < 1)
{
print("Timed out");
yield break;
}
if (Input.location.status == LocationServiceStatus.Failed)
{
print("Unable to determine device location");
yield break;
}
else
{
Debug.Log("Location can be retrieved!", distanceTextObject);
debugTextObject.GetComponent<Text>().text = "5!";
print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
...
}
Input.location.Stop();
}
Your answer
Follow this Question
Related Questions
Accessing sensors of iOS/Android devices 1 Answer
Convert LatLong values into unity coordinates and display hotspots in Camera View 0 Answers
Instancing LocationInfo upon each call or on Start 0 Answers
Launching "Locations and Security" Android Menu from Unity? 0 Answers
Embed device maps into unity 3D 0 Answers