1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using UnityEngine;
- using UnityEngine.UI;
- public class DropUnit : MonoBehaviour
- {
- public Text nameText;
- public Text digitText;
- public Image image;
- public GameObject bingObj;
- public Sprite[] sprites;
- private int index = 0;
- private float currentIndex = 0;
- public void Init(double lgtd,double lttd,string na,string di)
- {
- Vector3 temp = CoordinateConverter.GeoToUGUISmall(lgtd, lttd);
- this.GetComponent<RectTransform>().anchoredPosition3D = temp;
- image.sprite = sprites[0];
- nameText.text = na;
- digitText.text = di;
- currentIndex = 0;
-
- index = (int)Mathf.Clamp(Mathf.Round(float.Parse(di) / 2.0f), 0,9);
- }
- 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)];
- }
- }
- }
|