SateliteHudUpdater.cs 1002 B

12345678910111213141516171819202122232425262728
  1. using Google.Maps;
  2. using Google.Maps.Coord;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. /// <summary>
  6. /// A controller to update the Lat/Lng display in the HUD based on the world position of this
  7. /// <see cref="GameObject"/> translated to a <see cref="LatLng"/> through the
  8. /// <see cref="MapsService"/>.
  9. /// </summary>
  10. public class SateliteHudUpdater : MonoBehaviour {
  11. /// <summary>
  12. /// The <see cref="MapsService"/> used to translate world position to <see cref="LatLng"/>.
  13. /// </summary>
  14. [Tooltip("The MapsService used to translate world position to latlng.")]
  15. public MapsService MapsService;
  16. /// <summary>
  17. /// The <see cref="Text"/> UI element used to display <see cref="LatLng"/>.
  18. /// </summary>
  19. [Tooltip("The Text UI element used to display latlng")]
  20. public Text LatLngDisplay;
  21. void Update() {
  22. LatLng latlng = MapsService.Projection.FromVector3ToLatLng(transform.position);
  23. LatLngDisplay.text = string.Format("Lat/Lng: {0:F4},{1:F4}", latlng.Lat, latlng.Lng);
  24. }
  25. }