private bool m_locationEnabled = true;
public bool LocationEnabled
{
get
{
if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
{
Debug.LogError("LocationEnabled mobile=" + Input.location.isEnabledByUser);
return Input.location.isEnabledByUser;
}
return m_locationEnabled;
}
set
{
Debug.LogError("LocationEnabled=" + value);
m_locationEnabled = value;
}
}
只要这段代码,build成apk之后:
低精度:https://docs.unity3d.com/ScriptReference/LocationService.Start.html
Input.location.isEnabledByUser这个变量一直返回false,我们要将总的开启: