12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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 Sprite[] 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)
- {
- Vector3 temp = CoordinateConverter.GeoToUGUISmall(lgtd, lttd);
- this.GetComponent<RectTransform>().anchoredPosition3D = temp;
- nameText.text = na;
- //digitText.text = di;
- switch (we) {
- case "9":
- weatherText.text = "晴天";
- image.sprite = weatherSprite[0];
- break;
- case "8":
- weatherText.text = "阴天";
- image.sprite = weatherSprite[1];
- break;
- case "7":
- weatherText.text = "雨天";
- image.sprite = weatherSprite[2];
- break;
- case "6":
- weatherText.text = "雨夹雪";
- image.sprite = weatherSprite[3];
- break;
- case "5":
- weatherText.text = "雪天";
- image.sprite = weatherSprite[4];
- break;
- }
- }
- // Update is called once per frame
- void Update()
- {
- this.GetComponent<RectTransform>().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bingObj.transform.position) * 1920.0f / Screen.width;
- }
- }
|