ISAP/Assets/Scripts/UI/UILinkText.cs

41 lines
1003 B
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
public class UILinkText : MonoBehaviour, IPointerClickHandler
{
public TextMeshProUGUI txt;
private void Awake()
{
txt.text = "<link='°Ù¶È'><u>www.baidu.com</u></link>";
}
public void OnPointerClick(PointerEventData eventData)
{
Application.OpenURL(txt.text);
Vector3 pos = new Vector3(eventData.position.x, eventData.position.y, 0);
int linkIndex = TMP_TextUtilities.FindIntersectingLink(txt, pos, null); //--UIÏà»ú
if (linkIndex > -1)
{
TMP_LinkInfo linkInfo = txt.textInfo.linkInfo[linkIndex];
//Debug.Log(linkInfo.GetLinkText());
Application.OpenURL(linkInfo.GetLinkText());
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}