Search Unity

TMPro, Locate Letter, World Pos

Discussion in 'Scripting' started by renman3000, May 18, 2021.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi there,
    I am using TMPro, and was hoping to locate the World Position of any letter, in the text of a TextMeshPro.


    I have been looking around but it is not entirely clear.

    Thank you
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,694
    I'm going to guess such a feature is not exposed.

    EDIT: I stand corrected. See @Brathnann 's post below!

    However, you can look for yourself because TMPro is installed as source code.

    Put up a text field, attach the debugger and set some breakpoints in TMPro, press play and start trying to track down where the mesh is formed for the glyphs that make up the text field.

    If you find it, see if there is any API to get it. I'm not aware of any.

    It might be possible to make some tweaks to TMPro (you would have to break and pin the package to your project) to get a simple functionality like this.
     
    Last edited: May 18, 2021
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    renman3000 and Kurt-Dekker like this.
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697


    Thanks, I will go over... quick question tho... I was hoping to access a Texture, that TMPro would be accessing for its Font Atlas, however I can not see one.... would you know if there is a Texture, one could potentially access?

    Thank you
     
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    upload_2021-5-20_9-9-29.png

    Intellisense shows an atlas and atlasTexture option. So perhaps one of those.
     
  6. maewionn

    maewionn

    Joined:
    Jan 18, 2016
    Posts:
    38
    For everyone finding this, here is an easy to implement way:
    https://answers.unity.com/questions/1336562/textmesh-pro-characterinfo-coordinates.html
     
    Last edited: Feb 26, 2022