123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- 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 string[] childBtnNames = new string[] {
- "视频监控",
- "雨量监测",
- "水文监测",
- "水压监测",
- "水位监测",
- "位移监测",
- "泵站",
- "闸站"
- };
- public Action<int, RuntimePoint> onChildClick;
- public Button childBtnPrefab;
- public Button btn;
- public List<Button> listBtns = new List<Button>();
- public RectTransform childBtnParent;
- 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;
- public RectTransform addContent;
- void Awake() {
-
- // arrow.DOLocalMoveY(-40, 1.0f).SetLoops(-1, LoopType.Yoyo);
- }
- // Start is called before the first frame update
- void Start()
- {
- //this.GetComponent<Button>().onClick.AddListener(() =>
- //{
- // if (layerIDs.Count > 1)
- // {
- // addContent.gameObject.SetActive(true);
- // if (listBtns.Count < 1)
- // {
- // for (int i = 0; i < layerIDs.Count; i++)
- // {
- // Button button = Instantiate(childBtnPrefab);
- // button.GetComponent<RectTransform>().SetParent(childBtnParent);
- // int temp = i;
- // button.GetComponentInChildren<Text>().text = childBtnNames[layerIDs[i]];
- // button.transform.localScale = Vector3.one;
- // button.gameObject.SetActive(true);
-
- // button.onClick.AddListener(() =>
- // {
- // onChildClick?.Invoke(layerIDs[temp],this);
- // Debug.Log(layerIDs[temp]);
- // addContent.gameObject.SetActive(false);
- // });
- // listBtns.Add(button);
- // }
- // }
- // }
- // CameraManager.instance.secondCamera.GetComponent<CameraBirdSec>().beginDrag += () =>
- // {
- // addContent.gameObject.SetActive(false);
- // };
- //});
- }
- 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)
- {
- if (eventData.button == PointerEventData.InputButton.Left)
- {
- lastTime = Time.time;
- }
- }
- public void OnPointerUp(PointerEventData eventData)
- {
- if (eventData.button == PointerEventData.InputButton.Left)
- {
- if (Time.time - lastTime < 0.5f)
- {
- onPointClick?.Invoke();
- }
- }
- }
-
-
- }
|