12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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<int> layerIDs = new List<int>();
- 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<RectTransform>().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bingObj.transform.position) * 1920.0f / Screen.width;
- float bi = CameraManager.instance.secondCamera.GetComponent<CameraBirdSec>().currentDistance / 20;
- bi = (float)Math.Clamp(bi, 0.3, 1);
- this.GetComponent<RectTransform>().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();
- }
-
- }
- }
|