Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. 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

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

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

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

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    TextMesh Pro vs. TextMesh Web Demo
    This is as plain as it can get. A simple line of text being updated each frame using the same Arial font.


    Top text is TextMesh Pro. Bottom is Unity's Text Mesh.

    When the count reaches 1000, while still using the same TextMesh Pro Font Asset, we switch to a different material preset and then back later on.
     
  2. thinkofwhy

    thinkofwhy

    Joined:
    Jun 6, 2014
    Posts:
    3
    Just purchased TextMesh Pro, it's great, but,,...

    I've created TextMesh Pro prefabs and I need to get the mesh size during game but MeshInfo is null even after the prefab has been instantiated and the object is rendered. I'm sure it's populated only for the editor. So I tried everything else, like TextMeshPro.bounds, ... etc, but they're all null or zeroed. Where can I get mesh size during the game? Thanks for any help.
     
  3. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thank you!

    Are you instantiating the object via script?

    The mesh is typically updated once per frame before the scene is rendered. As a result, the object that you just instantiated doesn't really exists yet when you try to get its bounds.

    To force the object / mesh to be created when you need it, use TextMeshPro.ForceMeshUpdate(); which will update the mesh and then populate the bounds.

    The MeshInfo isn't ready yet for primetime but it will be soon. But for your needs, the bounds should be there.

    Let me know if this works. I'll be online for the next few hours so we can get this sorted out for you.

    P.S. Make sure you register on the TMPro Forum, which will make it easier for me to assist you.

    P.S.S. In the next release 0.1.43, a new function was added which is TextMeshPro.GetTextMetrics(text); which will return information such as # of characters, # of lines and # or words as well as the Height and Length of this potential text string. This will be useful to determine those metrics before creating the actual object.
     
    Last edited: Jun 6, 2014
  4. thinkofwhy

    thinkofwhy

    Joined:
    Jun 6, 2014
    Posts:
    3
    Thanks for the quick response.

    I used GetKeyDown() in Update() to trigger a request for the size, since the prefab is instantiated in a Start(), which is effectively where I requested it before, and now it works. Thanks.

    Don't know where the TMPro Forum is though.
     
  5. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    TextMesh Pro Forum
     
  6. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    P.S. This is a follow up post in the TextMesh Pro Asset Store Thread

    The creation of this Gold Material

    I wanted to show how this Gold material was created from the plain Impact SDF Font Asset. Once again, we are re-using the same (base) Impact SDF Font Asset. This is simply a new material with modified properties.


    Here is an image of the text using this new Gold Material preset.




    Close up on just the letter "G" reflecting the final settings of this material.




    Lastly, an animated GIF of the process for creating this new material preset.




    Let me know if you have any questions.
     
  7. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Just made some refinements to text justification in terms of handling line endings and paragraphs. The image below is a single text object using Justified Alignment mode with a blend of 50 / 50 between words and character spacing. The text was copy / paste from a webpage.


     
  8. MrScary

    MrScary

    Joined:
    Dec 8, 2007
    Posts:
    92
    Is there a fix for this? I require Multithreaded Rendering. Thanks
     
  9. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Not much I can do on my end since this is a Unity issue. According to the post below, multi-threaded rendering for Android appears to still be work in progress..

    I am not sure if this behavior is consistent from device to device.
     
  10. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Performance Comparison (Unity's Text Mesh vs. TextMesh Pro)
    This is somewhat of an extreme stress test as it is unlikely that you'll even have 5000 text objects on screen at once but just in case, you can count on TextMesh Pro to deliver in terms of visual quality and performance.





    Here is a still image of Unity's Text Mesh.




    and now a still of TextMesh Pro. Notice how much cleaner & more professional the text is using TextMesh Pro.

     
  11. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    Can this be rendered with PBR shaders?
    Affected by Skyshop lighting, CandelaSSR, etc?!
     
  12. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    The surface shader sets all the SurfaceOutput paramaters for downstreams shaders.

    struct SurfaceOutput { half3 Albedo; half3 Normal; half3 Emission; half Specular; half Gloss; half Alpha; };

    And the source code for all the scripts and shaders are provided for tweaking.

    People are welcome to visit http://digitalnativestudios.com/forum/ for in depth tech support.
    (I can provide custom shader help there if needed)

    I know this is not what you asked for directly, but this show the resulting shading being done by Unity when using the surface shader.
    (we fill in the SurfaceOutput structure, Unity does the rest)
    atr.jpg
    The scene consist of two TexMesh Pro objects (cursive is using the non surface shader, what you would attach to a camera or use for GUI), and a cube / Sphere on a bump mapped plane. with 2 point light and one directional.

    The glow is part of the emission output (a child light is used for the scene lighting)
    fog1.jpg

    Screen space effects will probably need a tweak regarding how the Zbuffer is updated....
    So I cant guaranty compatibility ATM.
     
    Last edited: Jun 9, 2014
  13. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    One of our users has discovered that TextMeshPro.SetText() which was designed as an alternative to using string.format or stringbuilder.appendFormat or the plain "Some string" + integer.ToString(); which all result in run time allocations, was incompatible with Windows Store builds as well as having issue with JIT compile mode. The reason for this was a result of using generic types and the iConvertible interface.

    I have reworked the SetText function and added overloads instead. As a result, it no longer uses generic types and this iConvertible interface which means it should now work on all platforms and compile modes. In addition, it got even faster.

    Code (CSharp):
    1. _StringBuilder.AppendFormat("The sum of {0} + {1} is {2}", 2, 3, 5); // 7830ms - 132 bytes of Allocations
    2. m_textMeshPro.SetText("The sum of {0:0} + {1:0} is {2:0}.", 2, 3, 5); // 260ms - 0 Allocations
    3.  
    Both functions produce the following text : "The sum of 2 + 3 is 5."

    The performance numbers and allocations were gathered from Iterating over these functions individually 1 million times followed by then checking allocations in update in the profiler.
     
  14. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Since you are one of the users who requested it ... here it is.


    Text Truncating & Ellipsis
    One of the features that was requested in the WIP Thread was using Ellipsis to indicate when a line or paragraph of text is truncated. As part of the improvements to line justification which will be part of the next Beta Release 0.1.44, I was able to add this new feature which works in conjunction with TextMeshPro.maxVisibleLine property.

     
  15. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    Cool, looking forward to the next release.
     
  16. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I posted the Release Notes for the next beta 0.1.44 in the Asset Store Thread.
     
  17. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    New Beta 0.1.44 has been submitted to Unity for review.
     
  18. Flyclops

    Flyclops

    Joined:
    Apr 19, 2013
    Posts:
    10
    This plugin looks pretty awesome. I can't find anywhere whether or not it supports dynamic fonts. We have an international user base and we need to support multiple character sets, so we rely on Unity's dynamic fonts to generate atlases on the fly based on characters actually needed. Does TextMeshPro support this?
     
  19. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    TMPro doesn't support TTF at run-time, so you need to convert from a TTF to TMpro native format.

    The goods thing with this is that there is no run-time overhead/allocation of any kind related to font usage, the bad is that TTF are super compact for CJK support.

    note: Not much have been done in term of CJK testing. But we know we can support about 5,000 character in a 2K texture. (Thats 1 meg or less as an asset)

    So I would like to see a CJK option based on the latest research. As it seem about 4000 character are in use, and that would be easy. So pick a font, selected all the chat languages you want to support. done

    note: If its not for a chat box.. best to feed your localization file. this way you get only the data you use.
     
    Last edited: Jun 18, 2014
  20. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    (didn't read through the whole thread)
    Is there a way to turn off the backside of the text?
     
  21. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I never thought someone would not want to see the pretty backside of the text. Oops. :)

    In the shaders, you can temporarily set the culling to "Cull Back" instead of "Cull Off"

    However, I will add a new property to enable this to be changed via scripts and a property in the Editor panel if you feel that is necessary.

    P.S. Please make sure you register on the TMPro user forum. That way we can explore this more in depth without boring everyone here with details :)


    EDIT: Already added the new property which is TextMeshPro.enableCulling = true;

    Right now this changes the culling mode for all objects using that Material. It could be made to instance the material but I am not sure it makes sense to have some text objects with it on and other with it off.
     
    Last edited: Jun 18, 2014
  22. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Easy to do with your instructions, may not be necessary to put it in the editor but might help someone else.
    No one wants to see the backside of the text of a sign, makes it seems abnormal.
    Was at the forum earlier but lost the URL now, post please?

    Thanks

    Edit: Found the forum URL in my recent tabs list:
    http://digitalnativestudios.com/forum/
     
  23. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here is the link: TextMesh Pro User Forum


    Although I have already implemented the feature, please add it to the feature request part of the forum which will be useful to other users.
     
  24. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    I will, as soon as I can register, think my Password software is blocking my efforts.
     
  25. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    No problem. Feel free to PM me if you have any issues with registration or anything.

    I am off to bed since it is almost 5:00 AM for me
     
  26. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,109
    This is really awesome asset am loving it. But there is ONE really serious issue which isn't really your fault, you probably didn't realize and it's kind of specific, but I think alot of people will find it an annoyance.

    You cannot animate Color32 values in Animation editor. This means that you cannot make a TextMeshPro object, then put an animation curve on it, and animate it's alpha or color changes how it currently is because all the colors are stored as Color32. Simply changing them to Color makes them available to the animation editor and you can attach a curve to them. So I have gone through and changed the Color32 values in TMPro_Private to just Color. This seems to not affect anything? Unless I am missing something. Does this affect performance or something else? If there is not good reason to be using Color32 you should change them to Color so those values can be animated with the animation editor. Or write some method or something which the Animation editor can control, but then forward to the Color32. Because being able to animate the color of text and fade in the text through the animation editor is something I will use alot.

    *edit*
    I actually just discovered that doesn't work as its the m_FontColor value which controls the color via script. Which when I change it to Color from Color32 throws an error. If this could be made Color instead of Color32 I think that'd be better for reasons I explained, it can be animated via the animation editor. However my current workaround is to create a new MonoBehavior called TextMeshProAnimator, which has an [executeineditormode] tag on it, and it has a public Color value which gets forwarded to the m_FontColor value. Then I can animate the TextMeshProAnimator value. This works just fine. But I think you should maybe implement something like this on your side. Either make all the value editable in the animation, or create wrapper hooks that can the animation editor can grab and utilize.
     
    Last edited: Jun 18, 2014
  27. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,109
    Also another feature I realize would be really awesome is if we could feed alpha images into the font generator to create a Distance field on graphic images and such to be rendered with the system.

    Also the ability to use the same font asset with different materials would be highly useful.
     
  28. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    It is pretty hard to anticipate all the things that people may want to do with any given tool. The whole point of releasing the Beta was to get TextMesh Pro in the hands of even more people to gather even more feedback to make sure the product lives up to expectations. In other words, keep the feedback coming and lets figure out what you need :)


    I see your issue here. Let me see what I can do to make the color properties work with the animation editor. I am surprised that Unity doesn't support color32 in their animator.

    Color is substantially slower (10 X slower) than Color32 when it comes to updating mesh data. Having said that, once I have a better understanding of what you are trying to accomplish, I can most likely add a new function or property to allow you to do what you want using color.

    Let's figure out how I can add the functionality you need in a way that it will benefit all other users as well :)


    EDIT: I am looking into this. I wish the Animation Editor used property accessors instead of changing serialized properties directly.
     
    Last edited: Jun 19, 2014
  29. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Are you looking to mix graphics (shapes) with the current text or looking to use these shapes instead of text in separate objects and taking advantage of the dynamic / flexibility of our rendering?
     
  30. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,109
    In this specific instance I am looking to use the shapes as separate objects.

    But I realize being able to mix objects in with the text would probably be very valuable too.

    I'm thinking, what if in the TextMeshAsset creator, you could specify an array of images, then a tag like 'circleshape', and also specify a font object, or not. Then in the text mesh pro mono behavior if you put a tag in the text field like <circleshape> it will then grab the image you fed it in the array. Or something like that. I just describe that to highlight the kind of functionality I would be looking for.

    if you point me where to sign up for the text mesh pro forum I will post my comments there so others can see them too
     
  31. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    One of the features that I would like to add is the ability to mix different fonts and sprites in the same text object. I started working on it and then got pulled in 5 different directions like making TextMesh Pro play nice with the Animation Editor for instance :)

    TextMesh Pro User Forum
     
  32. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here is a quick test using the Animation Editor to animated the color as well as character spacing.



    This is not the best looking animation but it should be a good enough proof of concept.

    EDIT: Looks like the challenging part of this will be to track when Unity is changing Serialized Properties via the Animation Editor.
     
    Last edited: Jun 19, 2014
  33. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The Outline is added at the edge and grows inwards & outwards. If having the Outline grow into the face of the character is not ideal, you can use Dilate to inflate the character to compensate. Here are a few examples:


    Image of the text - plain



    Image of text with an Outline extends both inward and outward. This makes the characters appear thinner.


    Image of text with the same Outline but with added Dilation to compensate for the outline. Face surface area is the same is the first image but now the Outline is effectively added on the outside of the face.


    Image of the same text but with an added soft drop shadow. Why? Just because we can :)

    Hopefully this answers your question. Let me know if you need further assistance.


    P.S. As a side note, all 4 of these examples are still using the same Arial SDF Font Asset. The only difference between these 4 text objects is their style which is amount to different material properties. Essentially, we are looking at the same Font Asset with 4 different materials.
     
  34. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Text Texturing Option in TextMesh Pro
    About a week ago, I mentioned that I was going to create a short video to go over the various text (face & outline) texturing options in Text Mesh Pro. Well here is that video :)

     
  35. Reiner

    Reiner

    Joined:
    Dec 2, 2012
    Posts:
    214
  36. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Just going through potential things to look at...

    Which shader are you using?

    Are you getting the same behavior in d3d9?

    Are you using one of the fonts included with TextMesh Pro?

    If you are using a new font, is this new Font Asset located in a resource folder?


    P.S. Take the time to register on the TMPro user forum when you have a chance.
     
    Last edited: Jun 26, 2014
  37. Reiner

    Reiner

    Joined:
    Dec 2, 2012
    Posts:
    214
    @Stepha B i wonder. everything looks good today. think i must restart unity after import textmesh pro and use it.


    today all is good :)


    i use dx11, with ssaa effect, color correction, desaturate effect, bloom, glow effect.
    player settings: forward, gamma
    quality: fantastic
    unity: unity pro

    one question: in my projekt the player has the possibility to change the resolution for the screen.
    is there a possibility that I can position the text on the basis of resolution. gui skins I can via script position so it always looks the same. "Screen.width" "Screen.height"?

    Greetz Reiner
     
  38. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You can certainly move the text object anywhere you want and position it based on some relationship of screen width and height. If you are trying to adjust the size of the text object based on the screen resolution, I would also adjust the point size base on the screen as well.

    http://digitalnativestudios.com/textmeshpro/docs/ScriptReference/TextMeshPro.html
     
  39. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,109
    It'd be cool if there was a drop down to select 'inward', 'outward' or 'both' and have it add or subtract the dilation amount exactly dependent on the outline.
     
  40. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I can certainly see where having the outline applied just on the outside of the edge would be handy as you would not need dilation to compensate for it. However, all these options comes at some cost on the shader side which has to be considered.
     
  41. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    Actually as I understand his suggestion works on the C# side, so outline works as now though when I set outline to 'outward' then, when I change its thickness, some dilate value added for 'Face' to compensate part which goes inside.
    Basically convenient way to do automatically what can be done now manually :)
     
  42. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Let me look at where to fit / add that option :)
     
  43. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Modifying an existing Font Asset
    What if you have already generated a bunch of font assets and need to add new characters or change the padding / spread? What if you have several materials that were duplicated from this existing material?

    Well fear not :) TextMesh Pro has you covered. Take a look at this video which explains the process.

     
  44. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    @techmage: Looks like we will be able to play a lot nicer with the Animation Editor in 4.6. So animating the TextMesh Pro properties like font color, character spacing, etc... will be much easier when 4.6 arrives :)
     
  45. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    @techmage: I forgot to mention that I switched over to using Color in the API which will make it work smoothly with the Animation Editor. Internally I still use Color32 due to its superior performance.
     
  46. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Single text object with a texture on the face + outline, bevel and shadow.

     
  47. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I was just informed by Chris West (SpookCat) that TextMesh Pro works nicely with his MegaFiers as well as MegaBook.
     
  48. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
    Screenshots? :)
     
  49. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
  50. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    New TextContainer Component
    This is a preview of the new TextContainer Component for TextMesh Pro. This new component will provide much better control over the layout of the text when it comes to alignment as well as masking due to the new margins.

    Also note worthy is the new Auto-sizing of the text to fit the TextContainer. As usual, I am looking for some feedback on this new feature / component.

     
Thread Status:
Not open for further replies.
unityunity