You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PhishingAwarenessSimulation/Assets/BodyLinkHandler.cs

52 lines
1.4 KiB
C#

1 month ago
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
public class BodyLinkHandler : MonoBehaviour, IPointerClickHandler, IPointerExitHandler
{
private TextMeshProUGUI tmp;
void Awake()
{
tmp = GetComponent<TextMeshProUGUI>();
}
void Update()
{
Camera eventCam = null;
// Try to get the event camera from the canvas (better than Camera.main)
if (tmp.canvas.renderMode == RenderMode.WorldSpace)
{
eventCam = tmp.canvas.worldCamera;
}
int linkIndex = TMP_TextUtilities.FindIntersectingLink(tmp, Input.mousePosition, eventCam);
if (linkIndex != -1)
{
CursorManager.Instance?.SetLinkCursor();
}
else
{
CursorManager.Instance?.SetDefaultCursor();
}
}
public void OnPointerClick(PointerEventData eventData)
{
int linkIndex = TMP_TextUtilities.FindIntersectingLink(tmp, Input.mousePosition, eventData.pressEventCamera);
if (linkIndex != -1)
{
string linkID = tmp.textInfo.linkInfo[linkIndex].GetLinkID();
Debug.Log("🔗 Clicked link: " + linkID);
EmailPopupManager.Instance?.ShowPopup(linkID);
}
}
public void OnPointerExit(PointerEventData eventData)
{
CursorManager.Instance?.SetDefaultCursor();
}
}