RuntimePoint.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using DG.Tweening;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.EventSystems;
  6. using UnityEngine.UI;
  7. public class RuntimePoint : MonoBehaviour,IPointerEnterHandler,IPointerExitHandler
  8. {
  9. public Button btn;
  10. public Image textBase;
  11. public Text text;
  12. public Image icon;
  13. public StaticImportant staticImp;
  14. public List<int> layerIDs = new List<int>();
  15. public RectTransform arrow;
  16. public GameObject bingObj;
  17. void Awake() {
  18. arrow.DOLocalMoveY(-40, 1.0f).SetLoops(-1, LoopType.Yoyo);
  19. }
  20. // Start is called before the first frame update
  21. void Start()
  22. {
  23. }
  24. public void InitPoint(Sprite newIcon, string name_pri, string newText) {
  25. text.text = newText;
  26. textBase.gameObject.SetActive(false);
  27. staticImp = StaticLod.instance.staticImportantsDic[name_pri];
  28. icon.sprite = newIcon;
  29. }
  30. // Update is called once per frame
  31. void Update()
  32. {
  33. this.GetComponent<RectTransform>().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bingObj.transform.position) * 1920.0f / Screen.width;
  34. }
  35. public void OnPointerEnter(PointerEventData eventData)
  36. {
  37. ((IPointerEnterHandler)btn).OnPointerEnter(eventData);
  38. textBase.gameObject.SetActive(true);
  39. textBase.fillAmount = 0;
  40. text.color = Color.clear;
  41. DOTween.To(() => textBase.fillAmount, x => textBase.fillAmount = x, 1, 0.25f).onComplete = ()=> {
  42. text.DOColor(Color.white, 0.25f);
  43. };
  44. }
  45. public void OnPointerExit(PointerEventData eventData)
  46. {
  47. ((IPointerExitHandler)btn).OnPointerExit(eventData);
  48. textBase.gameObject.SetActive(false);
  49. }
  50. }