Digital Native Studios

TextMeshPro => Support => Topic started by: toddmiller on January 03, 2016, 11:28:35 AM

Title: TMP_TextUtilities.FindIntersectingLink always returns -1
Post by: toddmiller on January 03, 2016, 11:28:35 AM
I have a TextMeshProUGUI component that I am trying to get links working for.

I attached a script to catch the pointer events and process a click event.
It has no problem catching the event but the link index is always -1.

Here is the method that catches the event.

public void OnPointerDown(PointerEventData eventData)
{
    int linkIndex = TMP_TextUtilities.FindIntersectingLink(tmp, Input.mousePosition, Camera.main);

    if (linkIndex == - 1)
        return;

    SendClickedEvent(linkIndex);
}

Here is my text:

<link="1">Strength 12</link>

My Canvas is using Screen Space - Overlay.
Any idea what I'm doing wrong?
Title: Re: TMP_TextUtilities.FindIntersectingLink always returns -1
Post by: Stephan B. on January 03, 2016, 12:16:47 PM
ScreenSpace overlay doesn't use a Camera so you need to pass null for the Camera.
Title: Re: TMP_TextUtilities.FindIntersectingLink always returns -1
Post by: somadevs on January 21, 2016, 12:26:48 PM
ScreenSpace overlay doesn't use a Camera so you need to pass null for the Camera.

Oh, I just ran into this as well!
Would you kindly document this behavior in the comments on FindIntersectingLink()?
Title: Re: TMP_TextUtilities.FindIntersectingLink always returns -1
Post by: Stephan B. on January 21, 2016, 01:58:13 PM
ScreenSpace overlay doesn't use a Camera so you need to pass null for the Camera.

Oh, I just ran into this as well!
Would you kindly document this behavior in the comments on FindIntersectingLink()?

I updated the comments for the TMP_TextUtilities class.