RealWorldTerrainUContextWaila.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* INFINITY CODE 2013-2019 */
  2. /* http://www.infinity-code.com */
  3. #if UCONTEXT
  4. using InfinityCode.uContext.Tools;
  5. using UnityEditor;
  6. using UnityEngine;
  7. namespace InfinityCode.RealWorldTerrain.ThirdParty
  8. {
  9. [InitializeOnLoad]
  10. public static class RealWorldTerrainUContextWaila
  11. {
  12. private static RealWorldTerrainContainer container;
  13. static RealWorldTerrainUContextWaila()
  14. {
  15. Waila.OnPrepareTooltip += OnPrepareTooltip;
  16. }
  17. private static string OnPrepareTooltip(GameObject go, string str)
  18. {
  19. RealWorldTerrainMonoBase item = go.GetComponent<RealWorldTerrainMonoBase>();
  20. if (item == null) return str;
  21. Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
  22. RaycastHit hit;
  23. if (!Physics.Raycast(ray.origin, ray.direction, out hit)) return str;
  24. double lng, lat, alt;
  25. item.GetCoordinatesByWorldPosition(hit.point, out lng, out lat, out alt);
  26. return str + "\nLatitude: " + lat + "\nLongitude: " + lng + "\nAltitude: " + alt.ToString("F2") + " m";
  27. }
  28. }
  29. }
  30. #endif