12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class WeatherUnit : MonoBehaviour
- {
- public Text nameText;
- public Text weatherText;
- public Image image;
- public GameObject[] weatherSprite;
- public GameObject bingObj;
- // Start is called before the first frame update
- void Start()
- {
-
- }
- public void Init(double lgtd, double lttd, string na, string we)
- {
- for (int i = 0; i < weatherSprite.Length; i++) {
- weatherSprite[i].gameObject.SetActive(false);
- }
- Vector3 temp = CoordinateConverter.GeoToUGUISmall(lgtd, lttd);
- this.GetComponent<RectTransform>().anchoredPosition3D = temp;
- nameText.text = na.Trim();
- //digitText.text = di;
- switch (we) {
- case "9":
- weatherText.text = "晴天";
- weatherSprite[0].gameObject.SetActive(true);
- break;
- case "8":
- weatherText.text = "阴天";
- weatherSprite[1].gameObject.SetActive(true);
- break;
- case "7":
- weatherText.text = "雨天";
- weatherSprite[2].gameObject.SetActive(true);
- break;
- case "6":
- weatherText.text = "雨夹雪";
- weatherSprite[3].gameObject.SetActive(true);
- break;
- case "5":
- weatherText.text = "雪天";
- weatherSprite[4].gameObject.SetActive(true);
- break;
- }
- }
- // Update is called once per frame
- void Update()
- {
- this.GetComponent<RectTransform>().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bingObj.transform.position) * 1920.0f / Screen.width;
- }
- }
|