Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

TextMesh Pro TMP_TextUtilities.FindIntersectingXXX always returning -1

Discussion in 'UGUI & TextMesh Pro' started by fdeimel, Apr 6, 2018.

  1. fdeimel


    Sep 7, 2017
    I´m trying to code a clickable link feature for TMP. After failing several times I found out that the FindIntersectingXXX Functions always return -1 for me. I tried an empty scene with a new canvas and TMPUGUI component but it still fails for me.

    any Ideas on the Problem?

    Code (CSharp):
    1. private void Update()
    2.     {
    3.         int wordIndex = TMP_TextUtilities.FindIntersectingWord(tmp_text, Input.mousePosition, Camera.main);
    4.         int linkIndex = TMP_TextUtilities.FindIntersectingLink(tmp_text, Input.mousePosition, Camera.main);
    5.         DebugPanel.Log("wordIndex", wordIndex);
    6.         DebugPanel.Log("linkIndex", linkIndex);
    7.     }
    Unity Version: 2017.3.1f1
  2. Stephan_B


    Unity Technologies

    Feb 26, 2017
    When using a Canvas which might be in screen space overlay, there is no camera per say. In this case, pass Null for the camera.
  3. Kilik1985


    Oct 10, 2022
    I pass null for the camera but the app does nothing when I click on a link. The code works when linkIndex != -1 but it's like the script stops working when I do click on a link.

    The variable linkIndex doesn't even get a value when I click on the link. I set a breakpoint on the line and I can't get any value, it's as if the code just doesn't execute anymore.

    EDIT: nothing to do with the script, sorry. My link was at the bottom of a viewport and clicks aren't being registered there. That's another issue I have to figure it out now
    Last edited: Dec 2, 2022