Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Where is the definitition for TMP_TextUtilities.FindIntersectingWord

Discussion in 'UGUI & TextMesh Pro' started by yusefkerr, Sep 4, 2020.

  1. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    162
    Hello, I'm trying to become more familiar with event systems and c# in general, and I'm confused about what's happening in "TMP_TextUtilities", which appears to be just a series of lines like

    "public static int FindNearestWord(TMP_Text text, Vector3 position, Camera camera);"

    To me, this looks like the first line of a method, but I can't find the method body. When it's used in TMP_TextEventHandler's LateUpdate() method, it just seems to magically return the index of the word under the mouse pointer. I can see that it's being passed the mouse position, text element, and camera, but where are the "inner workings" of FindNearestWord() that convert these arguments into the returned int?

    I hope this question makes sense, it's driving me a bit crazy.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,569
    The function implementation is all there, perhaps your IDE is only showing the function signature for some reason.

    What are you seeing in your IDE?
     
  3. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    162
    Code (CSharp):
    1. #region Assembly Unity.TextMeshPro, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    2. // C:\Users\44792\Desktop\SaintSimonSaw_20200903\SaintSimonSaw_CardSetup\Library\ScriptAssemblies\Unity.TextMeshPro.dll
    3. #endregion
    4.  
    5. using TMPro;
    6. using UnityEngine;
    7.  
    8. namespace TMPro
    9. {
    10.     public static class TMP_TextUtilities
    11.     {
    12.         public static float DistanceToLine(Vector3 a, Vector3 b, Vector3 point);
    13.         public static int FindIntersectingCharacter(TMP_Text text, Vector3 position, Camera camera, bool visibleOnly);
    14.         public static int FindIntersectingLine(TMP_Text text, Vector3 position, Camera camera);
    15.         public static int FindIntersectingLink(TMP_Text text, Vector3 position, Camera camera);
    16.         public static int FindIntersectingWord(TMP_Text text, Vector3 position, Camera camera);
    17.         public static int FindNearestCharacter(TMP_Text text, Vector3 position, Camera camera, bool visibleOnly);
    18.         public static int FindNearestCharacterOnLine(TMP_Text text, Vector3 position, int line, Camera camera, bool visibleOnly);
    19.         public static int FindNearestLine(TMP_Text text, Vector3 position, Camera camera);
    20.         public static int FindNearestLink(TMP_Text text, Vector3 position, Camera camera);
    21.         public static int FindNearestWord(TMP_Text text, Vector3 position, Camera camera);
    22.         public static int GetCursorIndexFromPosition(TMP_Text textComponent, Vector3 position, Camera camera);
    23.         public static int GetCursorIndexFromPosition(TMP_Text textComponent, Vector3 position, Camera camera, out CaretPosition cursor);
    24.         public static int GetHashCode(string s);
    25.         public static int GetSimpleHashCode(string s);
    26.         public static uint GetSimpleHashCodeLowercase(string s);
    27.         public static int HexToInt(char hex);
    28.         public static bool IsIntersectingRectTransform(RectTransform rectTransform, Vector3 position, Camera camera);
    29.         public static bool ScreenPointToWorldPointInRectangle(Transform transform, Vector2 screenPoint, Camera cam, out Vector3 worldPoint);
    30.         public static int StringHexToInt(string s);
    31.         public static char ToLowerFast(char c);
    32.         public static char ToUpperFast(char c);
    33.     }
    34. }
     
  4. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    162
    Here's a screenshot IDE.jpg
     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,569
    What version of Unity are you using?

    Looks like you are using the deprecated version of TextMesh Pro from the AssetStore.
     
  6. villevli

    villevli

    Joined:
    Jan 19, 2016
    Posts:
    68
    If you have installed TextMeshPro through package manager, you should find the source in <path-to-project>\Library\PackageCache\com.unity.textmeshpro

    Other option would be to decompile <path-to-project>\Library\ScriptAssemblies\Unity.TextMeshPro.dll with ILSpy.
     
  7. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    162
    Thanks for the replies, I'm using Unity2020.1.2, and I have TMP version 3.0.1. I couldn't remember how I got TMP, but it's activated in the package manager, and I haven't got any TMP files in my asset store history.

    I can access the folder you mention for \com.unity.texmeshpro and I can find the TMP_TextUtilities.cs file, which includes all the function bodies that were missing before, so that's great, I can at least see how they're working now.

    Is there likely to be any reason why these don't show up in visual studio? It feels like TextEventHandler is on a different "level" of accessibility than TMP_TextUtilities, for example, I can't find TMP_TextUtilities by searching in my Unity project. It also comes up in this purple tab on the right hand side of VS.
     
unityunity