I have 4 links, which are being created via this code:
public TextMeshProUGUI tmpText;
void Start()
{
tmpText.text =
"<link=Text1><color=blue><u>Text1</u></color></link>, " +
"<link=Text2><color=blue><u>Text2</u></color></link>, " +
"<link=Text3><color=blue><u>Text3</u></color></link>, " +
"<link=Text4><color=blue><u>Text4</u></color></link>";
}
And handling it via this code:
public class TextClickHandler : MonoBehaviour, IPointerClickHandler
{
private TextMeshProUGUI tmpText;
public static event Action<string> ClickedText;
void Awake()
{
tmpText = GetComponent<TextMeshProUGUI>();
}
public void OnPointerClick(PointerEventData eventData)
{
//Nur Gott weiß wieso das funktioniert
int linkIndex = TMP_TextUtilities.FindIntersectingLink(tmpText,Input.mousePosition,null);
if (linkIndex != -1)
{
TMP_LinkInfo linkInfo = tmpText.textInfo.linkInfo[linkIndex];
string clickedText = linkInfo.GetLinkID();
Debug.Log($"Clicked: {clickedText}");
ClickedText?.Invoke(clickedText);
}
}
}```
After firing the Event, I would like to delete the link from the TMPro Object, but I don't really know how to do that. I tried replacing the text with " " but that didn't seem to work, as nothing would happen.
Any ideas?
