Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro - Advanced Text Rendering for Unity - Beta now available in Asset Store

Discussion in 'Works In Progress - Archive' started by Stephan-B, Feb 11, 2014.

Thread Status:
Not open for further replies.
  1. adr3

    adr3

    Joined:
    Oct 2, 2015
    Posts:
    1
    Hi, i've been using TMPro commercial version for a while - and everything was working great until i've updated to unity 5.6. There is an error message for texts that use a fallback font. if i try to add a character that is not in the base font (so a submesh should be created), this error just pups up:

    Trying to remove bg (UnityEngine.UI.Image) from rebuild list while we are already inside a rebuild loop.
    This is not supported.
    UnityEngine.GameObject:AddComponent()
    TMPro.TMP_SubMeshUI:AddSubTextObject(TextMeshProUGUI, MaterialReference) (at Assets/TextMesh Pro/Scripts/TMP_SubMeshUI.cs:227)
    TMPro.TextMeshProUGUI:SetArraySizes(Int32[]) (at Assets/TextMesh Pro/Scripts/TMPro_UGUI_Private.cs:1288)
    TMPro.TMP_Text:parseInputText() (at Assets/TextMesh Pro/Scripts/TMP_Text.cs:1704)
    TMPro.TextMeshProUGUI:OnPreRenderCanvas() (at Assets/TextMesh Pro/Scripts/TMPro_UGUI_Private.cs:1512)
    TMPro.TextMeshProUGUI:Rebuild(CanvasUpdate) (at Assets/TextMesh Pro/Scripts/TextMeshProUGUI.cs:227)
    UnityEngine.Canvas:SendWillRenderCanvases()

    should i switch to the free version that goes with unity 5.6 release, would it help?
    or is there a chance this will be fixed somehow in the future ? (hopefuly also for the depreciated commercial TMPro version)

    thanks!
     
    Last edited: Apr 28, 2017
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    As per my many posts about this topic, I strongly recommend you remain on the commercial version of TextMesh Pro for which I will continue to provide updates and support on the TextMesh Pro user forum as I have done over the past several years.

    In terms of this specific error, this is not an error specific to TextMesh Pro. This is a result of a change made by Unity which had unforeseen consequences affecting several users including those using TextMesh Pro. As such Unity will be revising how the particular issue they were trying to address will be handled to avoid this new limitation / error. A fix is expected to be available in the next patch release of Unity or perhaps the subsequent one.
     
  3. redmotion_games

    redmotion_games

    Joined:
    May 6, 2013
    Posts:
    84
    Hi Stephan,
    If I wanted to trigger a method in another script by clicking a link in a Textmesh Pro object, how would this be set up?

    There is one example that reacts to hovering over the link but not a mouse click. Would it be possible for you to add another version of 12a where clicking the link fires off an event to another monobehaviour method, please?
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Take a look at the TMP_TextEventHandler.cs script which is what is used to trigger these events. In the current implementation in the LateUpdate() function, TMP checks if the mouse position intersects with a given character, word or link.

    In order to have it react to a mouse click, you just need to modify this to instead of just checking for a mouse position, it also checks if you have clicked.
     
  5. felipeap92

    felipeap92

    Joined:
    Jan 7, 2014
    Posts:
    8
    Hello Stephan,

    Is it possible to do a "inversed mask" with TextMesh Pro + some UI Element (Image)?? I mean, i want to make the UI Element becomes transparent whatever the text is. Something similar to THIS and THIS.

    Thanks. =]
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    It is not at the present time as TMP doesn't set up the stencil buffer for this use case. This is something I can look into when I have a chance.
     
    felipeap92 likes this.
  7. GavJocatop

    GavJocatop

    Joined:
    Jan 26, 2017
    Posts:
    4
    Hi, Stephan.

    I'm trying to create a TMP on runtime, and I'm having trouble with alignment.

    First, is there an up-to-date API documentation somewhere ?

    And for my problem : even if I set myTMP.alignment to TextAlignOption.Center, my text is not center, horizontally or vertically.

    How can I do that ?

    Thank you.
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Most of the information would be contained on the TextMesh Pro user forum and release notes. Some of the example scenes / scripts should also contain examples of this. Also be sure to check the following docs as well.

    Here is an example of setting alignment on a TMP_Text object.

    Code (csharp):
    1.  
    2.  m_text.alignment = TextAlignmentOptions.Center;
    3.  
    If this still doesn't work for you, please provide an example of the script you are using.

    P.S. Since it is 5:00 AM for me, I am going to go sleep but I'll check back tomorrow.
     
  9. GavJocatop

    GavJocatop

    Joined:
    Jan 26, 2017
    Posts:
    4
    That's what I did, but the text stays aligned top left.

    Although, I'm sorry, I forgot to mention that I'm using a TextMeshProUGUI object, not a TextMeshPro.

    Here's my script :

    Code (csharp):
    1. TextMeshProUGUI cText = oElement.AddComponent<TextMeshProUGUI>();
    2. cText.richText = true;
    3. cText.SetText(oElementXML["text"].InnerText);
    4. cText.alignment = TextAlignmentOptions.Center;
    5. cText.color = Color.black;
    oElement is a GameObject, and oElementXML is a XMLNode. oElementXML["text"] is some RichText :
    "<b>Qu'est-ce que le système solaire ?</b>"

    The bold tag does not appear in the text, and appears to be correctly interpreted and used.

    Thank you for your concern and prompt reply.
     
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Add the following script to an empty game object that is a child of a Canvas and let me know if that works correctly for you.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using TMPro;
    4.  
    5. public class Sandbox : MonoBehaviour {
    6.  
    7.     private void Awake()
    8.     {
    9.         TMP_Text textComponent = gameObject.AddComponent<TextMeshProUGUI>();
    10.  
    11.         textComponent.text = "This is a line of text.";
    12.  
    13.         textComponent.alignment = TextAlignmentOptions.Center;
    14.     }
    15. }
    16.  
    This works correctly for me.
     
  11. GavJocatop

    GavJocatop

    Joined:
    Jan 26, 2017
    Posts:
    4

    Yes, it did work. So, I guest the problem is in the interactions with the rest of my code.
    I'll run some tests, and let you know.

    Thank you.
     
  12. GavJocatop

    GavJocatop

    Joined:
    Jan 26, 2017
    Posts:
    4
    Okay, after some tests, it seems that the problem come from the fact that my object is inactive by the time I add to it the TMP. When I turn it active, the alignment is not respected.

    Please try this :
    • Set the GameObject RectTransform to the full canvas dimensions.
    • Add your test script to the Canvas instead of the empty GameObject.
    • Add a public member to the script, and set it to the GameObject in the editor.
    • Modify the script so it add the component to this member instead of "this".
    • Set the GameObject state to inactive.
    • Start the application, and then manually switch the state of the GameObject to active.
    Please tell me if you have the same behaviour than me (text is not centered), and if you do, if you have a solution for that.

    Thank you.
     
  13. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Is this fixed yet? Specific to TMPro or not - this essentially renders your product completely unusable for projects upgraded to 5.6.

    Who is to blame is irrelevant, it would be great if there was some sort of direction on how to resolve.

    So should we go back to 5.5? Is there a update coming to the asset store? Is there an update coming to Unity? Or is there an beta update over on the Digital Native forums?

    Has to be said, congratulations on becoming part of the Unity team - sadly at this time I can't even hit play in my project using TMPro without being spammed with errors. :( Thanks.
     
  14. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Some of the issues in Unity 5.6 have been addressed in some of the Unity 5.6 patches. I also made some changes in the latest release of TMP which is available on the user forum as well as on the Asset Store. Have you tried the latest release to see if you still get the same issue?
     
  15. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    I see on the patch notes it says to download the correct version, but when opening the asset store you can only download the automatically selected version right? It shows the Unity 5.6 version instead of the 2017 version if I am seeing this correctly. Any known fix for this? I've seen it talked about by you and in a couple other threads.
     
  16. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There is no release for Unity 2017.1 on the Asset Store due to a bug which prevents publishers from uploading releases for Unity 2017.1 to the Store.

    I posted a link to the 2017.1 release in the sticky thread in the Unity UI & TextMesh Pro user forum section.
     
  17. bhavinpanara22

    bhavinpanara22

    Joined:
    Jul 5, 2013
    Posts:
    126
    Hello,

    How do I write Hindi text properly. If I write it, it's screwed in both Unity UI & TextMesh Pro also.
    Please guide me.
    Examples included for Unity & TextEdit(on mac). See the difference.
    Screen Shot 2017-07-11 at 12.01.54 PM copy.png
    Screen Shot 2017-07-11 at 12.07.41 PM.png
    Thanks.
     
  18. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    TextMesh Pro does not currently support ligatures and gsub tables which is what I believe results in the incorrect text rendering with Hindi right now.

    As you may know, I am busy re-writing TextMesh Pro to integrate it into Unity. As I am doing a full re-write, I am also including support for Ligatures and font features which is essential to support languages like Hindi, Arabic, Thai, etc.

    I don't yet have an ETA on when this new version will be available be I am working on it.

    P.S. There might be some TextMesh Pro users who have created their own Hindi parser where a script would convert these ligatures. You might want to ask in the Unity UI & TextMesh Pro section of the forum if anyone has such a script.
     
  19. bhavinpanara22

    bhavinpanara22

    Joined:
    Jul 5, 2013
    Posts:
    126
    Thanks for your reply. I will ask there. And I will be waiting for TextMesh to support GSUB & GPOS.
     
    Stephan_B likes this.
  20. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Is it possible to upgrade to the asset store version of TMP (when fixed) later on?
     
  21. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hi Stephan
    Can I have different extra Settings, like Face and Outline using the same font material?
    In the past I have had two different FontAssets using the same actual font. Not sure if this is correct way to do it.

    Thanks
     
  22. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What do you mean by extra settings for face or outline?

    Are you using Material Preset to handle your different visual styles?
     
  23. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    OMG, I so didn't know how to make additional Material Presets.

    Thank you so much.
     
    Stephan_B likes this.
  24. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The ability to create and use Material Presets is fundamental and essential to understand as it provides great flexibility when trying to manage and style text objects. It is also very efficient as Material Presets reference the font atlas texture of the font asset from which they are derived thus avoiding resource duplication.
     
  25. Omaek

    Omaek

    Joined:
    Jan 26, 2014
    Posts:
    7
    Hi Stephan B, thanks, the possibility to render fonts at any resolution (with outline and other features) is amazing!
    But I'm missing the possibility to do the same thing with sprites.
    Is there any chance you could provide a version of the SDF shader that renders sprites (independently of texts)?
     
  26. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What makes it possible to render the characters cleanly at any resolution is the use of SDF which requires we compute and the SDF for each character and store / encode it in a font atlas texture. When we do this, we use a binary representation of the characters (ie. black or white pixels).

    The same could be done with shapes and symbols but not with color images (ie. sprites). Just like characters, we could add an outline, shadow and textures to them.

    There are many TMP users who use websites like icomoon.io where you can import SVG shapes and add them to a custom font where you can then import it into Unity and use TMP to create an SDF Font Asset out of it. This is the same process when using FontAwesome.

    P.S. Here is an experimental prototype that I played with using shapes.

     
    Last edited: Jul 16, 2017
    Peter77 and Omaek like this.
  27. Omaek

    Omaek

    Joined:
    Jan 26, 2014
    Posts:
    7
    Thats exactly what I meant.
     
  28. thehen2

    thehen2

    Joined:
    Apr 1, 2014
    Posts:
    54
    I'm trying to use maxVisibleCharacters to display my text, but I want the container to expand with it. Currently it looks like the hidden text still affects the container. Any way I can solve this?
     
  29. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You will have to take a look at the textInfo and sub structures like characterInfo[] which contain information about the text object, characters, words, lines, etc. Using this information in conjunction with maxVisibleCharacters, you should be able to determine the size / position of the last visible character or line to adjust the size of your container.
     
  30. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    Is it possible to do an Emissive text? Like a keyboard backlight
     
  31. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You can experiment with the Glow property on the shader to see if you can get close to the results you seek.
     
  32. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    tried that, it's not quite right
     
  33. bonsaisushi

    bonsaisushi

    Joined:
    May 18, 2017
    Posts:
    34
    Will localization traductions be implemented? Like putting translation boxes under the TMP component, with a script recognizing the device language, those boxes will be filled by the user with the translations for the language

    Example
    Eng "Hello"
    Ita "Ciao"
    Ger "Hallo"

    Hope i was clear enough for what I meant, sorry english is not my native language
     
  34. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    TextMesh Pro like other Unity text components in their simplest forms are designed to take some text input, perform some layout pass based on some text container dimensions and to display the text.

    Handling / Management of the content of the text input is the role of a localization / content management tool. There are several of them available on the Asset Store such as I2 Localization and a few others.
     
    bonsaisushi likes this.
  35. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    since there is the surface shader and i can let text cast shadows and stuff. when i place the text in worldspace why is it not visible in reflection etc. it is writing to zbuffer than?
     
  36. ArnoldRauers_Tinytouchtales

    ArnoldRauers_Tinytouchtales

    Joined:
    Jan 25, 2015
    Posts:
    33
    Hi,
    i've come across an issue with accessing the sorting order. It seems that the Sorting Layer and Sorting Order option form the extras panel is not exposed in code. I know i can use MeshRenderer to set the Sorting Order for plain text. But when i have a sprite icon within my text this does not work since the sprite has it's own Sorting Order as it seems. It would be great if i could set the Sorting Order via code and it should also automatically adjust the order for any sprites within my text.

     
  37. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Since the Text Component and Sub Text Objects each use a Mesh Renderer, you can set those via code by accessing the mesh renderer API directly.

    The ability to access the sorting order and layer ID on the text component is a convenience which I guess I could modify when I have time to also set the sorting order and layer ID to match that of the child sub objects.
     
  38. seanrod

    seanrod

    Joined:
    Jan 13, 2015
    Posts:
    52
    Cannot display Sprite.
    1. I have an Assets>Sprites folder with the source art in it.
    2. Created a TextMesh Pro: Sprite Asset.
    3. I have an Assets>Resources>Sprites folder with the "Title_FreeSpin" sprite in it.
    There is only one sprite with an index 0; OX:0​
    4.In the input box, I have: X<sprite="Title_FreeSpin" index=0>X

    However, the sprite will not display. All I see is X<sprite="Title_FreeSpin" index=0>X on screen.
    Help please.
     
  39. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The location of the Sprite Asset is defined in the TMP Settings file. The default location used to be in "Resources/Sprites/..." but this was changed several releases ago to be "Resources/Sprite Assets/..." to avoid confusing between Sprites and Sprite Assets. This location is user definable.
     
  40. seanrod

    seanrod

    Joined:
    Jan 13, 2015
    Posts:
    52
    Just found a field to drag in the sprite, and the sprite shows up.
    After creating a Text Mesh object, you will see an "Extra Settings" tab. Open up the tab and you will see a "Sprite Asset." Drag the Sprite into this field and you will see your Sprite.

    Thank you for the tool, Text Mesh Pro is awesome!
     
  41. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    As you indicated, you can assign a Sprite asset to individual text objects.

    Since you can also reference a Sprite asset by name using <Sprite="Sprite Asset Name" index=0> you still want to make sure to place your Sprite assets in the location specified in the TMP Settings file. The TMP Settings file is located in the "TextMesh Pro/Resources/..." folder.
     
  42. Boolable

    Boolable

    Joined:
    Jun 28, 2015
    Posts:
    19
    Hi @XaneFeather, did you find a solution for that ?
     
  43. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    I know I used it before, but I can't seem to find it and thought I just had the wrong name, but is the Text info debug tool no longer included with TMP? I had to dig around and saw it was in one of your older videos and I do remember using it, but can't seem to find it in the 5.6 version of TMP that I got off the TMP forum.

    Thanks!
     
  44. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The TMP_TextInfoDebugTool.cs is still in there and is located in "TextMesh Pro/Examples/Scripts/..."
     
  45. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    Ah, ok. I didn't bring in the examples into this project. Didn't realize the debug script was in there. Didn't think about that.

    Thanks!
     
  46. Skjalg

    Skjalg

    Joined:
    May 25, 2009
    Posts:
    211
  47. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You could look at using a symbol library like FontAwesome which would contain circle and shapes or use a website IcoMoon which allows you to include SVG shapes and create a font out of it. From any of these font file, create a Font Asset that includes these shapes and assign them either to a text object or use them as a fallback (general in the TMP Settings file).
     
  48. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Hi Stephan, any update on when we might see 3D text (extruded)? That would be really nice in VR.
     
  49. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Unfortunately, not in the short term as I am focusing on the re-write / integration of TMP into Unity. However, once that is done, I will certainly be looking into adding new features and I agree that adding support for 3D characters or Volumetric text would be super cool.
     
    ibyte likes this.
  50. flyingbanana

    flyingbanana

    Joined:
    Jan 28, 2014
    Posts:
    22
    I'm looking at localization and OpenType fonts that support variations on glyphs based on language through the locl feature, and I'm wondering whether this would be possible at all to get on Unity. It seems quite hard to even get any information on the topic! Any thoughts?
     
Thread Status:
Not open for further replies.