RuntimePoint.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using DG.Tweening;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.EventSystems;
  7. using UnityEngine.UI;
  8. public class RuntimePoint : MonoBehaviour
  9. {
  10. public Button btn;
  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 Refresh(Sprite newIcon) {
  25. Debug.Log(newIcon);
  26. Debug.Log(bingObj.name);
  27. icon.sprite = newIcon;
  28. }
  29. public void InitPoint(Sprite newIcon, string name_pri, string newText) {
  30. text.text = newText;
  31. if(name_pri.Trim().Length > 0)
  32. staticImp = StaticLod.instance.staticImportantsDic[name_pri];
  33. icon.sprite = newIcon;
  34. }
  35. // Update is called once per frame
  36. void LateUpdate()
  37. {
  38. this.GetComponent<RectTransform>().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bingObj.transform.position) * 1920.0f / Screen.width;
  39. float bi = CameraManager.instance.secondCamera.GetComponent<CameraBirdSec>().currentDistance / 20;
  40. bi = (float)Math.Clamp(bi, 0.3, 1);
  41. this.GetComponent<RectTransform>().localScale = Vector3.one / bi;
  42. }
  43. }