using TMPro; using UnityEngine; using UnityEngine.EventSystems; [RequireComponent(typeof(TMP_Text))] public class LinkText : MonoBehaviour, IPointerClickHandler { public void OnPointerClick(PointerEventData eventData) { TMP_Text pTextMeshPro = GetComponent(); int linkIndex = TMP_TextUtilities.FindIntersectingLink(pTextMeshPro, eventData.position, eventData.pressEventCamera); // If you are not in a Canvas using Screen Overlay, put your camera instead of null if (linkIndex != -1) { TMP_LinkInfo linkInfo = pTextMeshPro.textInfo.linkInfo[linkIndex]; DebugUtil.Log("OnPointerClick called."); DebugUtil.Log("Link ID: \"" + linkInfo.GetLinkID() + "\" Link Text: \"" + linkInfo.GetLinkText()); Application.OpenURL(linkInfo.GetLinkID()); } } }