Author Topic: TMP_TextUtilities.FindIntersectingLink always returns -1  (Read 2562 times)

toddmiller

  • Newbie
  • *
  • Posts: 10
TMP_TextUtilities.FindIntersectingLink always returns -1
« 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?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5685
Re: TMP_TextUtilities.FindIntersectingLink always returns -1
« Reply #1 on: January 03, 2016, 12:16:47 PM »
ScreenSpace overlay doesn't use a Camera so you need to pass null for the Camera.

somadevs

  • Newbie
  • *
  • Posts: 36
Re: TMP_TextUtilities.FindIntersectingLink always returns -1
« Reply #2 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()?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5685
Re: TMP_TextUtilities.FindIntersectingLink always returns -1
« Reply #3 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.