123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- public class IconTools : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
- {
- public GameObject infoImage;
- public Image img_bg;
- int Index = 0;
- [SerializeField] float offsetX = 0;
- [SerializeField] float offsety = 0;
- bool Isenter = false;
- public void OnPointerEnter(PointerEventData eventData)
- {
- if (infoImage != null)
- {
- infoImage.SetActive(true);
- if (DataManager.Instance.exceptionList.Count > 0)
- {
- infoImage.GetComponentInChildren<Text>().text = DataManager.Instance.exceptionList[DataManager.Instance.exceptionList.Count - 1 - Index].Time+":"+ DataManager.Instance.exceptionList[DataManager.Instance.exceptionList.Count - 1 - Index].ExceptionMessage;
- }
- Isenter = true;
- }
- }
- public void OnPointerExit(PointerEventData eventData)
- {
- if (infoImage != null)
- {
- infoImage.SetActive(false);
- Isenter = false;
- }
- }
- // Start is called before the first frame update
- public void SetId(int id)
- {
- Index = id;
- }
- // Update is called once per frame
- void Update()
- {
- if (infoImage.activeSelf && Isenter)
- {
- infoImage.transform.position = Input.mousePosition + new Vector3(offsetX, offsety, 0);
- img_bg.transform.position = infoImage.GetComponentInChildren<Text>().transform.position;
- img_bg.rectTransform.sizeDelta = new Vector2(infoImage.GetComponentInChildren<Text>().GetComponent<RectTransform>().rect.width, infoImage.GetComponentInChildren<Text>().GetComponent<RectTransform>().rect.height);
- }
- }
- }
|