SWHeightUnit.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class SWHeightUnit : MonoBehaviour
  6. {
  7. public Text nameText;
  8. public Text valueText;
  9. public GameObject bingObj;
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. }
  14. public void Init(string slgtd, string slttd, string na, string we)
  15. {
  16. double lgtd = double.Parse(slgtd);
  17. double lttd = double.Parse(slttd);
  18. Vector3 temp = CoordinateConverter.GeoToUGUI(lgtd, lttd);
  19. nameText.text = na;
  20. float value = 0.0f;
  21. if(float.TryParse(we,out value))
  22. valueText.text = value.ToString("0.00");
  23. this.GetComponent<RectTransform>().anchoredPosition3D = temp;
  24. }
  25. // Update is called once per frame
  26. void Update()
  27. {
  28. this.GetComponent<RectTransform>().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bingObj.transform.position) * 1920.0f / Screen.width;
  29. }
  30. }