116 lines
3.2 KiB
C#
116 lines
3.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 线缆列表信息
|
|
/// </summary>
|
|
public class LineRendererInteraction : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
|
{
|
|
public LineRenderer lineRenderer;
|
|
public GameObject popupUI;
|
|
private bool isMouseHovering = false;
|
|
|
|
public LineInfor lineInfor;
|
|
public BoxCollider boxCollider;
|
|
|
|
public string port_A;
|
|
public string port_A_cabinet;
|
|
public string port_A_deviceName;
|
|
public string port_B;
|
|
public string port_B_cabinet;
|
|
public string port_B_deviceName;
|
|
|
|
public CableUI cableUI;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
//Debug.Log("版本号 1.1.1");
|
|
//cableUI.port_A.text = this.port_A;
|
|
//cableUI.port_A_cabinet.text = this.port_A_cabinet;
|
|
//cableUI.port_A_deviceName.text = this.port_A_deviceName;
|
|
//cableUI.port_B.text = this.port_B;
|
|
//cableUI.port_B_cabinet.text = this.port_B_cabinet;
|
|
//cableUI.port_B_deviceName.text = this.port_B_deviceName;
|
|
//Debug.Log("版本号 1.1.1");
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
//if (!gameObject.activeInHierarchy || !popupUI || !GameManager.Inst.magnifyState)
|
|
// return;
|
|
//// 检测鼠标是否悬停在 LineRenderer 上
|
|
//if (isMouseHovering)
|
|
//{
|
|
// Debug.Log("11###");
|
|
// PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
// // 显示弹出 UI
|
|
// popupUI.SetActive(true);
|
|
// lineInfor.setcolor(Color.red);
|
|
//}
|
|
//else /*if (!isMouseHovering && popupUI.activeSelf)*/
|
|
//{
|
|
// Debug.Log("22###");
|
|
// // 隐藏弹出 UI
|
|
// popupUI.SetActive(false);
|
|
// lineInfor.setcolor(lineInfor.newColor);
|
|
//}
|
|
}
|
|
|
|
private void OnMouseEnter()
|
|
{
|
|
// 当鼠标进入 LineRenderer 区域时触发
|
|
isMouseHovering = true;
|
|
|
|
//Debug.Log("11###");
|
|
PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
// 显示弹出 UI
|
|
cableUI.port_A.text = this.port_A;
|
|
cableUI.port_A_cabinet.text = this.port_A_cabinet;
|
|
cableUI.port_A_deviceName.text = this.port_A_deviceName;
|
|
cableUI.port_B.text = this.port_B;
|
|
cableUI.port_B_cabinet.text = this.port_B_cabinet;
|
|
cableUI.port_B_deviceName.text = this.port_B_deviceName;
|
|
popupUI.SetActive(true);
|
|
lineInfor.setcolor(Color.red);
|
|
}
|
|
|
|
private void OnMouseExit()
|
|
{
|
|
// 当鼠标离开 LineRenderer 区域时触发
|
|
isMouseHovering = false;
|
|
|
|
//Debug.Log("22###");
|
|
// 隐藏弹出 UI
|
|
popupUI.SetActive(false);
|
|
lineInfor.setcolor(lineInfor.newColor);
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
//isMouseHovering = true;
|
|
|
|
//Debug.Log("11###");
|
|
//PatternChoose.Inst.sb_ck_page.SetActive(false);
|
|
//// 显示弹出 UI
|
|
//popupUI.SetActive(true);
|
|
//lineInfor.setcolor(Color.red);
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
//isMouseHovering = false;
|
|
|
|
//Debug.Log("22###");
|
|
//// 隐藏弹出 UI
|
|
//popupUI.SetActive(false);
|
|
//lineInfor.setcolor(lineInfor.newColor);
|
|
}
|
|
}
|