LocationPluginInterface.cs 722 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEngine;
  2. using System.Runtime.InteropServices;
  3. using AOT;
  4. using System;
  5. public class LocationPluginInterface
  6. {
  7. #if UNITY_IOS
  8. // 访问本地插件接口的声明
  9. [DllImport("__Internal")]
  10. private static extern bool _startUpdatingLocation(IntPtr resultHandler);
  11. [DllImport ("__Internal")]
  12. private static extern void _stopUpdatingLocation();
  13. #endif
  14. // 开始获取位置信息
  15. public static bool StartUpdatingLocation(IntPtr resultHandler)
  16. {
  17. #if !UNITY_EDITOR && UNITY_IOS
  18. return _startUpdatingLocation(resultHandler);
  19. #else
  20. return false;
  21. #endif
  22. }
  23. // 停止获取位置信息
  24. public static void StopUpdatingLocation()
  25. {
  26. #if !UNITY_EDITOR && UNITY_IOS
  27. _stopUpdatingLocation();
  28. #endif
  29. }
  30. }