Search Unity

TextMesh Pro TMP_TextUtilities.FindIntersectingXXX always returning -1

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

  1. fdeimel

    fdeimel

    Joined:
    Sep 7, 2017
    Posts:
    4
    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

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    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

    Kilik1985

    Joined:
    Oct 10, 2022
    Posts:
    2
    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
  4. ursxiz

    ursxiz

    Joined:
    Jun 18, 2020
    Posts:
    7
    It's possible that the plane distance on the canvas camera or order in the layer is set wrong.

    Try to change those values.