| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | using System;using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class WeatherUnit : MonoBehaviour{    public Text nameText;    public Text dropText;    public Image image;    public GameObject[] weatherSprite;    public Sprite[] sprites;    public GameObject bingObj;    private int index = 0;    private float currentIndex = 0;    // Start is called before the first frame update    void Start()    {            }    public void Init(double lgtd, double lttd, string na, string we,float drop)    {        for (int i = 0; i < weatherSprite.Length; i++) {            weatherSprite[i].gameObject.SetActive(false);        }        dropText.text = drop.ToString();        Vector3 temp = CoordinateConverter.GeoToUGUISmall(lgtd, lttd);        this.GetComponent<RectTransform>().anchoredPosition3D = temp;        nameText.text = na.Trim();        image.sprite = sprites[0];        currentIndex = 0;        index = (int)Mathf.Clamp(Mathf.Round(drop / 2.0f), 0, 9);        switch (we) {            case "9":                weatherSprite[0].gameObject.SetActive(true);                break;            case "8":                weatherSprite[1].gameObject.SetActive(true);                break;            case "7":                weatherSprite[2].gameObject.SetActive(true);                break;            case "6":                weatherSprite[3].gameObject.SetActive(true);                break;            case "5":                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;        if (index > currentIndex)        {            //Debug.Log((int)(currentIndex));            currentIndex += Time.deltaTime;            image.sprite = sprites[(int)(currentIndex)];        }    }}
 |