SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

4 years ago
  1. using UnityEngine;
  2. namespace ARLocation
  3. {
  4. public class MockLocationProvider : AbstractLocationProvider
  5. {
  6. public override string Name => "MockLocationProvider";
  7. public override bool IsCompassEnabled => true;
  8. public Location mockLocation = new Location();
  9. protected override HeadingReading? ReadHeading()
  10. {
  11. var mainCamera = ARLocationManager.Instance.MainCamera;
  12. var transform = mainCamera.transform;
  13. var localEulerAngles = transform.localEulerAngles;
  14. return new HeadingReading
  15. {
  16. heading = localEulerAngles.y,
  17. magneticHeading = localEulerAngles.y,
  18. accuracy = 0,
  19. isMagneticHeadingAvailable = true,
  20. timestamp = (long)(Time.time * 1000)
  21. };
  22. }
  23. protected override LocationReading? ReadLocation()
  24. {
  25. return new LocationReading
  26. {
  27. latitude = mockLocation.Latitude,
  28. longitude = mockLocation.Longitude,
  29. altitude = mockLocation.Altitude,
  30. accuracy = 0.0,
  31. floor = -1,
  32. timestamp = (long)(Time.time * 1000)
  33. };
  34. }
  35. private bool requested = true;
  36. protected override void RequestLocationAndCompassUpdates()
  37. {
  38. requested = true;
  39. }
  40. protected override void UpdateLocationRequestStatus()
  41. {
  42. if (requested)
  43. {
  44. Status = LocationProviderStatus.Initializing;
  45. requested = false;
  46. }
  47. if (Status == LocationProviderStatus.Initializing)
  48. {
  49. Status = LocationProviderStatus.Started;
  50. }
  51. }
  52. }
  53. }