66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LineRendererInteraction : MonoBehaviour
|
|
{
|
|
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()
|
|
{
|
|
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;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!gameObject.activeInHierarchy || !popupUI || !GameManager.Inst.magnifyState)
|
|
return;
|
|
// 检测鼠标是否悬停在 LineRenderer 上
|
|
if (isMouseHovering)
|
|
{
|
|
// 显示弹出 UI
|
|
popupUI.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
// 隐藏弹出 UI
|
|
popupUI.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void OnMouseEnter()
|
|
{
|
|
// 当鼠标进入 LineRenderer 区域时触发
|
|
isMouseHovering = true;
|
|
}
|
|
|
|
private void OnMouseExit()
|
|
{
|
|
// 当鼠标离开 LineRenderer 区域时触发
|
|
isMouseHovering = false;
|
|
}
|
|
}
|