IOS平台下,Unity无法获取GPS,IOS平台下Unity无法获取GPS
我在项目中想要获取用户的GPS,我使用了Unity自带的API。 在测试了Android,正常的获取到了GPS。但是在IOS平台下,我发现我无法获取GPS位置
1.我加了权限,一开始我只加了Privacy - Location When In Use Usage Description,后来我认为是权限不够,又增加了Privacy - Location Usage Description & Privacy - Location Always Usage Description
2.我有了解到可能需要在iPhone_Sensors.mm下修改一些东西,我在LocationService::StartUpdatingLocation里增加了如下代码(在网上找到的)
#if PLATFORM_IOS
//下面是我新增的
if ([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) {
[locationManager requestWhenInUseAuthorization];
}//到这儿结束
[locationManager startUpdatingLocation];
#else
[locationManager requestLocation];
#endif
3.我的Xcode提示我:Location service updates are not enabled. Check LocationService.status before querying last location. 我查看了设备的GPS打开了,查看了APP权限是可以获取GPS信息的。
4.在我的IEnumerator里,我发现并没有遇到什么错误,直接到了,我返回正常数据的那一步,只是N&E是0,其他的数值也是(当然,我无法确定是否真的走到了我的那一步。。。)
Your answer
![](https://koobas.hobune.stream/wayback/20220612145353im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
,Problem with Unity Android unity 5 1 Answer
How to recognize ar contents through webcam?? 0 Answers
Local Multiplayer Input 0 Answers
WheelColliders problem 1 Answer
Android Resolver Java Problem 0 Answers