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

Text Mesh Pro - The Ultimate Text Solution for Unity - Powerful & Flexible - Advanced Text Rendering

Discussion in 'Assets and Asset Store' started by Stephan-B, May 29, 2014.

Thread Status:
Not open for further replies.
  1. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    It is always best to find the correct font for the given language you wish to use otherwise you end up with potentially very different looking characters.
     
  2. MirzaBeig

    MirzaBeig

    Joined:
    Dec 27, 2014
    Posts:
    602
    The issue is that with the transliteration I've got mixed Latin/Arabic symbols and none of the source text (for Arabic and the transliteration) is my own. I also barely know Arabic, and the app itself is a learning tool so it's certainly an interesting development process!
     
  3. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    As per the post that I linked from the TMP User Forum, the character range of 600-6FF doesn't cover all the Arabic characters. This is really the range that you want

    600-6FF,750-77F,8A0-8FF,FB50-FDFF,FE70-FEFF,10E60-10E7F,1EE00-1EEFF

    Alternatively, you could consider using the "Characters from File" option where you would use the a text file that contains all the text that will be used in your project. Although this text file should be parsed to exclude duplicate characters, you can still use the raw text in there. Tools like I2 Localization also include an option to extra all the unique characters for a given language that you can then use with TMP and the "Character from file" option to generate your font assets.

    Unless you have user input where you may not know all the characters ahead of time, this is a good option. Otherwise, just use the range I provided above.

    I also recommend you post on the TMP user forum in the RTL thread since most users paying attention to that thread are fluent in Arabic (which I not not either btw).
     
  4. MirzaBeig

    MirzaBeig

    Joined:
    Dec 27, 2014
    Posts:
    602
    Thanks Stephan! I'll register now. Just gotta dig up my invoice.

    EDIT: Done! Awaiting approval.

    The range from the link was just from a Google search. I did use the range you posted in your forums when doing the first tests.

    Also, it seems the fallback method with the Arabic as the backup is working well since most of the transliteration characters are Latin but the symbols then default to what I'd like them to be. I would have used the characters-from-file option, but the transliteration source I'm using isn't "clean" and I'm currently parsing through all the text and taking out the parts I don't need, then converting the formatting, etc. programmatically. The purely Arabic parts, on the other hand, I have the source text files available for-- and that's how I'm generating the font assets for that.
     
    Last edited: May 11, 2016
  5. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    Hey Stephan,
    Is there a way to replace all Unity UI Text components through TextMeshPro components? Maybe a script?
    That would be neat.
     
    MV10 likes this.
  6. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    There are a few posts on the TextMesh Pro Forum which include user created scripts to do that. Here is a link to one of those http://digitalnativestudios.com/forum/index.php?topic=399.0
     
    johanneskopf likes this.
  7. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Made some good progress today on adding support for Rich Text with the TMP Text Input Field.

     
  8. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    Thanks for the link!
    Maybe you can include the most useful user created script, to replace the Unity UI Text with Text Mesh Pro, right into your package? :)
     
  9. ickydime

    ickydime

    Joined:
    Nov 20, 2012
    Posts:
    110
    Question on performance and sorry if this is covered.

    What kind of draw calls can I expect compared to unity's text mesh? I'm using a custom font and GUI/3D Text Shader so I can batch. However, when the artist adds a drop shadow he is doing so by creating a second TextMesh and placing it behind the first... which isn't ideal.

    I am curious if this tool batches?
    Do drop shadows/glows/etc cause extra draw calls?
    Do drop shadows/glows/etc break batching?

    I am targeting Hololens where every draw call counts.
     
  10. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Draw calls and batching in Unity is mostly based on the number of materials used. When creating custom fonts in Photoshop (for example), you are creating / importing new fonts which include their unique Font Atlas Texture + Material and in order for Bitmap fonts to render correctly, you also need to do this for each point size as bitmap fonts don't scale very well. So for every single visual treatment / style, you will end up with a new font and material.

    When using TextMesh Pro, you will only need (1) SDF Font Asset per font (ie. Arial, Impact, Bangers, etc) for all point size and resolution. Even if you had 100's of different visual treatments, you would still only have (1) SDF Font Asset for those which is very efficient.

    All these visual styles (treatments) are achieved by tweaking Material properties like Dilation, Outline, Shadow, Softness, Bevel, Glow, Textures for the face or outline, etc. TextMesh Pro offers different shaders which provide different levels of features. The performance of the shaders vary based on functionality available but all of them work on Mobile devices.

    To retain and recall these visual styles, you will be creating and working with Material Presets (see the following video which explains all of this). See the following video which covers Font Asset Creation.

    Now back to the original question. Since draw calls are based on the number of material used, you will get (1) draw call per material preset used. These material presets are just material and like all others will batch if you are using Dynamic Batching. So if you have 30 text objects using ARIAL SDF with different point size and between them 5 different Material Presets, you will get (5) draw calls.

    Since Materials can be changed at run time via code, you can also create material instances and change the material properties dynamically.

    The number of visual styles that can be achieved is virtually unlimited and yet you are still using a single SDF Font Asset.



    Another key advantage of using TMP (TextMeshPro) for VR type stuff is the fact that the text will render cleanly at any point size, resolution and zoom. Unlike a bitmap font which will look horrible as you get close to it, that is not the case with TextMesh Pro using SDF Font Assets.



    Hopefully, I provided the information you are looking for. Let me know if you have any other questions.
     
    johanneskopf likes this.
  11. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    Since Unity can/will batch mesh that share the same material,
    Textmesh Pro text object batch more often then tesxtmesh because the rendering is done in 1 pass/1 mesh no matter what rendering option is enabled.

    Any text, no matter what option is enabled, can batch with other text with the same option enabled.

    So :
    - The draw call reduction, specially if you use outline & shadow can be *massive*
    - The triangle count/overdraw is also reduce by 5x. So you get more benefits then just reduced drawcalls.
    - Yes, TextMesh Pro object will batch, as it follow Unity batching rules and by design is batching friendly.
    - No, glow, shadow, etc.. do not generate extra draw call (it doesn't even generate extra geometry at all)
    - No, glow, shadow, etc.. do not break batching.

    Stephan can probably give you performance difference, but if you enable outline/shadow TMPro is significantly faster.
    Mainly because its reduce overdraw by about 5x (very fillrate friendly). But its also lighter on the CPU.
     
  12. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The next release of TextMesh Pro (which should be within the next 7 days or so) will include the ability to use an Alpha Mask Texture as seen in this example.



    This will work with the 2D Rect Mask which was introduced in Unity 5.2. Note that it could work without it but I'll add that functionality shortly thereafter.

    Here is an animated GIF of this in action. The GIF compression is pretty bad here but you get the idea :)

     
    johanneskopf likes this.
  13. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    I'm curious about the use-case that led you to add this... why would someone obscure text? Can the mask be animated, perhaps (which might allow a kind of reveal effect)?
     
  14. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This has been requested by several users where the text usually scrolls through some viewport which has rounded corners or some irregular contour.

    Yes. That's the next step which is to provide some control over this alpha mask texture.
     
  15. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Made some improvements to the Sprite Asset Editor to provide the ability to Add & Delete sprites from your existing Sprite Assets.

    This will make it a lot easier to manage the sprites referenced in your sprite assets but also provide the ability to reference the same sprite multiple times but with different settings like position or scale for instance. Below you can see the revised Sprite Asset Editor panel.

     
    Tinjaw likes this.
  16. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here is some creative use of the <indent> and <sprite> tag to create bullets and numbered lists.

     
  17. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Add control over the Masking Texture to make it possible to animate both softness and transition to create Visual FX patterns to the visibility of the text.



    You can also inverse the pattern as well as add a color tint to the transition.
     
    MV10 likes this.
  18. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I'm trying to animate the color of a TextMeshProUGUI object, but even though the properties for the object are all available in the Unity Animation editor, when I click on any of them they do not get added to the Animation for modification. I'm using Unity 5.2.4p1 and TextMesh Pro Version 0.1.54 Beta 3. Any known issues with this?

    EDIT: Nevermind. Dumb mistake on my part. The list doesn't show the + add buttons unless you scroll to the right. I thought you could just double click it, but you have to click the + button and it wasn't visible without scrolling.
     
  19. hww

    hww

    Joined:
    Nov 23, 2007
    Posts:
    58
    Got latest version from Assets store, should it support multi-font feature?

    Without font tag it render text correctly
    Screenshot 2016-05-31 00.46.25.png With font tag it render all characters broken
    Screenshot 2016-05-31 00.46.04.png
     
  20. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Only the release for Unity 5.2 / 5.3 and 5.4 on the Asset Store does. For Unity 5.0 & 5.1, you need to get the release from the TextMesh Pro user forum.

    Note: There is a bug with the Asset Store where it may not provide the correct version of an Asset based on the version of Unity that you are using. So it is always best to get your releases from the TextMesh Pro user forum which ensures you always get the release you want.

    The version number of TMP is located in the header of the TextMeshPro.cs file.
     
  21. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    I was wondering how well TMPro integrates within UGUI since I've never seen any screenshots or videos where it is integrated into a full ui like windows, hud, popups etc.

    Any infos on that?
     
  22. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    As a customer, I can say TMPro works great with Unity UI. It has a Unity UI component that works as a drop-in replacement for Unity UI's Text component.
     
    Stephan-B likes this.
  23. fabiobp

    fabiobp

    Joined:
    Jan 16, 2016
    Posts:
    8
    Hi, I'm using TextMeshPro to display integer number, like 1,2,3,4 nothing big. I'm using setText() to set my number as text (myNumber.ToString()). It displays ok, no problem. But when I try to read the text using the "text" property, it return nothing but it's display some text. What's going on?
    Thanks.
     
  24. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Is there any reason you are using the SetText() function instead of just the .text property?

    The SetText() function is designed for combining a string with values like m_Text.SetText("The number is {0}.", value);

    It is designed to avoid using .ToString() and doing string concatenations.

    Using the following code for example does print the correct results.
    Code (csharp):
    1.  
    2. m_TextComponent = gameObject.AddComponent<TextMeshPro>();
    3.  
    4. m_TextComponent.SetText("The number is {0}.", 5);
    5.  
    6. Debug.Log(m_TextComponent.text);
    7.  
     
  25. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    As per @TonyLi reply, TextMesh Pro includes (2) text components. One that replaces the old Text Mesh and the other replacing UI.Text.

    Here is a link to a video showing how to access the two text components.

    There are also over a dozen videos on my YouTube channel showing examples that are using the Canvas Renderer. Below is another one.

     
  26. fabiobp

    fabiobp

    Joined:
    Jan 16, 2016
    Posts:
    8
    Hi Stephan, the property "text" seems to have some refresh problems that setText doesn't. So when I change the value using the property nothing happens in the screen. Although it works with the method. Furthermore, isn't it a bit confusing to have 2 different ways to do the same thing (to set a text)? Wouldn't it be better to have only one method like getText() and setText() that would internally do the correct treatment of the string. and eliminate the properties? Also setText() doesn't change the textbox on the editor, while "text" property does!
     
  27. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You would have to provide an example of the code you are using that results in this behavior as it should be working.

    The example code I provided above uses the .text property and works correctly.

    These functions have their purposes. The SetText() function was created to enable combining a short string with a value to avoid using string concatenation and allocations on the calling side.

    The SetText() function can also be used with StringBuilder as per the following post on the TextMesh Pro user forum.

    The SetCharArray() function which can also be used to set the text has it own purposes.

    The .text property is the primary method of setting the text and is not limit to short strings. Since TextMesh Pro is a replacement for Text Mesh and UI.Text which use properties like .text, .font or .fontSize, it mirrors their properties to make it easier to switch.

    Correct. SetText() is designed to be used via scripting and only updates the Text Input Box in the editor when in play mode.
     
  28. RckCnd

    RckCnd

    Joined:
    Jun 7, 2016
    Posts:
    3
    Hey, Stephan.
    Would like to get that nice extension, so having a question about license.
    How does team license will work?
    It says "1 license per seat". Will the other project members be able to see it (not edit) if I get one for myself? Or if they need to get license as well?
    Thank you!
     
  29. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    TextMesh Pro is an Editor Extension and as such requires (1) license per seat / installation. Therefore each project member which opens the project containing TextMesh Pro will require a license.
     
  30. RckCnd

    RckCnd

    Joined:
    Jun 7, 2016
    Posts:
    3
    Thats pity there is no team license for something like 10-12 members.
    Thanks anyway.
     
  31. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I do offer discounts for multiple licenses (10+) as well as Site and Company licenses which is what most of my larger customers are using.

    If you want pricing for 10+ licenses, just email me or PM me.
     
  32. RckCnd

    RckCnd

    Joined:
    Jun 7, 2016
    Posts:
    3
    Pm sent
     
  33. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hello there

    I'd like to know if TMP would let stylize Text?
    See my screenshot.

    As you can see I am showing the letters of the alphabet and I am using this code to change the value of the letter during runtime:
    Code (CSharp):
    1.  
    2. public Text _aText;
    3.  
    4. public void SetLetterValue () {
    5.         _aText.text = LetterName;
    6. }
    I saw the first video on the asset store description for Text Mesh Pro but it was more like a comparison than an enhancement to the UGUI text.

    What options do I have to use my UGUI implementation with TMP and how much work will I need to do replace my Text UGUI element with TMP entirely?

    Also, in terms of performance which is the most efficient? My young users would be swiping/moving that Text element and it'll be repositioned back to the center and updated constantly depending on the direction they swiped.

    Hope that makes sense and thanks!
     

    Attached Files:

  34. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Visual styling in TextMesh Pro is done by modifying material properties to add things like Dilation, Outline, Shadow, Bevel, etc. to the text. To save / recall these visual styles for your different SDF Font Assets, you will be creating Material Presets. The ability to dynamically style the text via material properties and using Material Presets allows you to have an unlimited number of visual styles.

    See the following video about the Font Asset Creation process and the following video about Creating and Working with Material Presets.

    To access the TextMeshPro components, you will need to include the TMPro namespace
    Code (csharp):
    1.  
    2. // Similar to how you need to reference the namespace for the UI using
    3. using UnityEngine.UI;
    4.  
    5. // You will need to add the TextMesh Pro namespace below
    6. using TMPro;
    7.  
    The code will be very similar as most of the TextMesh Pro properties mirror those used by Unity.

    Code (csharp):
    1.  
    2. // This is the only change required
    3. public TMP_Text _aText;
    4.  
    5. public void SetLetterValue () {
    6.         _aText.text = LetterName;
    7. }
    Note that TextMesh Pro include two text components. One designed to replace Text Mesh and the other UI.Text. Both TextMesh Pro classes inherit from TMP_Text which is what I used above. However, when adding a text component via script you need to refer to the specific classes which are TextMeshPro and TextMeshProUGUI.

    There are several scripts / examples with TextMesh Pro that you can look at to learn most of these things.

    The first video covers the Rendering and Visual aspect of the tool whereas the second video covers the text formatting and layout enhancements and improvements.

    TextMesh Pro provides all the functionality of the UI.Text component and a lot more. Most of this is shown in the second video as well as several other videos in my YouTube Channel.

    There are a few user created scripts available on the TextMesh Pro user forum to replace UI.Text components by TextMeshProUGUI components. Here is a link to one of them http://digitalnativestudios.com/forum/index.php?topic=752.msg5772#msg5772

    TextMesh Pro either matches or performs better than Unity's Text Components in all respect.

    See the following thread / post which provides additional information including benchmarks http://forum.unity3d.com/threads/text-asset.389456/#post-2537157

    Here is an example of getting a reference to the text object, assigning a Font Asset and Material Preset via script.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using TMPro;
    5.  
    6.  
    7. public class Example_01 : MonoBehaviour
    8. {
    9.     private TMP_Text m_Text;
    10.     private string m_label = "A simple line of text.";
    11.  
    12.     void Awake()
    13.     {
    14.         // Get a reference to the text component.
    15.         m_Text = GetComponent<TMP_Text>();
    16.  
    17.         // Assign the text string
    18.         m_Text.text = m_label;
    19.  
    20.         // Load and assign an SDF Font Asset
    21.         m_Text.font = Resources.Load<TMP_FontAsset>("Fonts & Materials/IMPACT SDF");
    22.  
    23.         // Load and assign a material preset
    24.         m_Text.fontSharedMaterial = Resources.Load<Material>("Fonts & Materials/IMPACT SDF - Drop Shadow");
    25.     }
    26. }
    27.  
     
    Last edited: Jun 11, 2016
  35. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here is the updated video about the <sprite> tag in TextMesh Pro which covers the recent improvements and the Sprite Asset creation process along with explanation of the Sprite Asset Editor features and functionality.

     
  36. matazematratze

    matazematratze

    Joined:
    May 3, 2015
    Posts:
    9
    Looks awesome! I have one question though. Is there a possibility to render the Text on da given surface; of a Unity sphere for example?
     
  37. AnneDraaisma

    AnneDraaisma

    Joined:
    Jul 14, 2014
    Posts:
    14
    Hi,

    Is there a way to use font presets similar to css? I would like to define my titles, headers and button text for instance. Material presets handle the looks, but the size, justification and other text options must be manually set for each Textmesh Pro object.

    Thanks you advance.
     
  38. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The text can be rendered to a Render Texture which can then applied to an object as a texture.

    Alternatively, you can also use and modify the WarpText.cs script located on the TMP user forum and instead of bending the text vertically, modify the script to bend the text to wrap it around a sphere. I believe there is an example in the thread as well.
     
    matazematratze likes this.
  39. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Yes. You can create and use <style> tags in TextMesh Pro. See the following video about the <style> tags.

     
  40. AnneDraaisma

    AnneDraaisma

    Joined:
    Jul 14, 2014
    Posts:
    14
    Thanks, Stephan! I can't believe I missed this :)
     
  41. v3_matt

    v3_matt

    Joined:
    Aug 10, 2015
    Posts:
    8
    Stephan,

    Ever since updating Text Mesh Pro, the \n character does not appear to be causing new lines. Is this a known issue, or is there a new tag? Thank you!
     
  42. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The behavior was changed in the last release to make it consistent with UI.Text and how such string would print using Debug.Log.

    This change should not have affected the results when using the .text property or the SetText function.

    The change will have an effect when the text is typed in the Text Input Box as using "\n" won't get parsed anymore so you will have to enter use / press enter or enable the "Parse Escape Character" option in the Extra Settings.

    There was also an issue with I2 Localization where the string was changes from something like "\n" to "\\n" which would result in escaping the carriage return which would then become the two characters "\" and "n".

    I believe a similar issue would be observed using PlayMaker.

    Some users have also reported this related to when they import the text via XML where the XML parser escapes the /n and converts it to "\\n".

    If you can provide an example of the text or string that you are using which produces the different result, it would be helpful for me to verify everything is behaving correctly.
     
  43. v3_matt

    v3_matt

    Joined:
    Aug 10, 2015
    Posts:
    8
    I believe my issue is as you stated, but I will confirm. We have a json serializer that is saving our data, and I bet it is escaping the \ and creating \\n. Thank you!

    Edit: Confirmed.
     
    Last edited: Jun 14, 2016
  44. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Glad you isolated the issue and thank you for letting me know.
     
  45. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    OMG this asset is amazing!!

    I'm implementing a HUD interface in my app and utilizing the old computer terminal script. In my case the text needs to by dynamic to display flight diagnostics. So on certain events I update the TextMeshProUGUI text component. Any idea how I can maintain the current text being displayed (e.g. scroll position), and just append more info to be displayed?

    The following updates the text, but it restarts the scrolling each time it's changed:

    Code (CSharp):
    1.     public string HUDText
    2.     {
    3.         set
    4.         {
    5.             m_hudText.text += value;
    6.  
    7.         }
    8.     }
    9.     private TextMeshProUGUI m_hudText;
    10.  
    11.     void Awake ()
    12.     {
    13.         m_hudText = this.GetComponent<TextMeshProUGUI>();
    14.         if(m_hudText == null)
    15.         {
    16.             throw new UnityException("HUDText missing TextMeshProUGUI component");
    17.         }
    18.     }
    19.  
     
  46. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I'll take a look tonight and provide you with an updated Text Console Simulator.
     
  47. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Release 0.1.54 Beta 4 of TextMesh Pro is now available on the TMP user forum. Be sure to review the release notes.
     
  48. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    @blamejane New Release of TextMesh Pro includes an update script for the old computer terminal which should allow you to add to the existing string without resetting the reveal.

    Just let me know if you need further assistance on this.
     
    hopeful likes this.
  49. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    Wow, thanks so much Stephan!! So I'm registering on the TMPro user forum, but where would I find my invoice number? Do you know where unity stores this in the account settings or download tab for the asset store?

    UPDATE: I found it and have just finished the registration :) (waiting for approval)
     
    Last edited: Jun 15, 2016
  50. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I just approved your registration. You will find the latest releases in the "TMPro - Alpha & Beta Releases" section of the user forum. Latest releases are always sticky with the release number and what version of Unity they are for in the title.
     
Thread Status:
Not open for further replies.