using DG.Tweening; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class RuntimePoint : MonoBehaviour,IPointerDownHandler,IPointerUpHandler { public Button btn; public Text text; public Image icon; public StaticImportant staticImp; public List layerIDs = new List(); public RectTransform arrow; public GameObject bingObj; public Action onPointClick; public float lastTime; void Awake() { // arrow.DOLocalMoveY(-40, 1.0f).SetLoops(-1, LoopType.Yoyo); } // Start is called before the first frame update void Start() { } public void Refresh(Sprite newIcon) { Debug.Log(newIcon); Debug.Log(bingObj.name); icon.sprite = newIcon; } public void InitPoint(Sprite newIcon, string name_pri, string newText) { text.text = newText; if(name_pri.Trim().Length > 0) staticImp = StaticLod.instance.staticImportantsDic[name_pri]; icon.sprite = newIcon; } // Update is called once per frame void LateUpdate() { this.GetComponent().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bingObj.transform.position) * 1920.0f / Screen.width; float bi = CameraManager.instance.secondCamera.GetComponent().currentDistance / 20; bi = (float)Math.Clamp(bi, 0.3, 1); this.GetComponent().localScale = Vector3.one / bi; } public void OnPointerDown(PointerEventData eventData) { lastTime = Time.time; } public void OnPointerUp(PointerEventData eventData) { if (Time.time - lastTime < 0.5f) { onPointClick?.Invoke(); } } }