Search Unity

Text asset?

Discussion in 'General Discussion' started by Rasly2, Mar 3, 2016.

  1. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    Can someone recommend me a text asset? I know people like text mesh pro but I am not sure. I just need clear not pixilated small text and decent outlines. I relay like "UITextEffect" asset but its not clear if small text is any better with it.

    If any one got experiences with different text assets, please share, I am specially interested in performances differences.
     
  2. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    There are sort of 3 common ways to get text with an outline.

    The first method is to use an external font tool to create a font with an outline or photoshop. This results in some font data along with a font atlas texture which contains all the characters in this bitmap texture. Since this font atlas texture is static, if you need a different point size or need a thicker outline or an outline of a different color, you need to create another font so you end up with as many fonts / textures as you have variations. From a visual point of view, as long as the font is rendered at the point size it was created, the outline and text will look nice. From a performance point of view, each character is rendered into two triangles which is efficient. This is using a bitmap font so as you zoom in, it will get pixelated.

    The second method is to use Unity's UI.Text with the Outline and Shadow FX scripts (assuming you also want shadows). This is implemented by those scripts duplicating and stamping the current text (4 times in the case of the outline) with an offset in order to create the outline. From a visual stand point as seen below, this is not accurate.

    upload_2016-3-3_2-53-38.png

    In that image, I used an offset value of 5 and -5 in order to make it easier to see how it is done. When using a thinner outline and small font it can look ok. Since these offset values are in pixels, as you change the point size of the text, the outline gets thinner or thicker. All this might be ok however, the real issue with this technique is that it more than quadruples the geometry which results in a significant performance impact which you can see in the table below. Since this is still using a bitmap font, as you zoom in, it will get pixelated.

    The third method is what TextMesh Pro does where the outlines and / or shadows are done by the shader and made possible by the use of SDF (Signed Distance Field) Font Assets which you create with the included Font Asset Creator. Unlike a bitmap font atlas texture where the pixels in the texture represent the shape of the characters, the SDF Font Atlas texture contains distance information to represent the shape of the characters. More precisely, for each pixel a distance to the nearest edge of the character is stored in this static SDF Font Atlas texture. Since the distance to the nearest edge of the characters is a constant, this text will render correctly at any point size and zoom factor and will never get pixelated. Since the outline thickness is relative to this distance, as the point size changes, the outline thickness remains proportional. See the image below of the same word at the same point size.

    upload_2016-3-3_2-54-19.png

    You can clearly see how clean the outline and soft shadow look. Unlike the first method where you need to create a new font atlas texture for each point size, thickness, color, etc... Only (1) single SDF Font Asset is required to create as many permutations as you want and for any given point size. In order to get different looks, you simply tweak the material properties and create material presets to recall those different looks. Here is an example where all I did was play with the material properties.

    upload_2016-3-3_3-0-6.png

    Now from a performance point of view, each character is still rendered into two triangles. Although the shader(s) have to do more work than plain bitmap shaders, when using outline and shadow it is marginal.

    Here is a chart comparing UI.Text vs. TextMesh Pro. These tests were done in Unity 5.3.3p1 using the latest release of TextMesh Pro available on the user forum. These tests were done on an Android Galaxy Tab A. Time (ms) is that of Canvas.SendWillRenderCanvases() which is where the text is generated by both UI.Text and TextMeshProUGUI. These tests were done using the Canvas system.

    upload_2016-3-3_3-34-50.png
    Geometry count is that of text "Outline #0" or 9 visible characters. Although UI.Text + Outline + Shadow is 5X slower than TextMeshPro, the time (ms) is still small enough where the device is still hitting 60 fps.


    Here are the results of a previous test done on my Desktop PC several months ago.


    This is the text / rendering results for this older test.

    Top text is UI.Text bottom is TextMeshPro.

    I have no data on how UITextEffect compares both from a visual and performance stand point.

    This information only covers the rendering and performance differences between UI.Text and TextMeshPro. TextMesh Pro offers a lot more functionality in terms of text formatting options and layout. It now includes over 36 rich text tags including support for multiple fonts and sprites per text object, font fallback, stylesheet, hyperlink support, etc...

    Here is a simple example of the Multi Font & Sprites functionality which is in the latest release (again only available on the user forum at this time and soon to be released on the Asset Store).

    TextMesh Pro - Reveal Multiple Fonts & Sprites.gif

    The reveal FX is done by using the .maxVisibleCharacters property which is a simple integer that controls how many characters should be visible. This does not involve any string operation (ie. GC free), ensures the text word wraps correctly all the time and works with all rich text tags and alignment options.

    Hopefully, I provided you with information that will help you get a better idea of how TextMesh Pro compares to UI.Text and potential ways to deal with text with an outline. Should you have any questions, please feel free to ask.
     
    Last edited: Mar 12, 2016
    Rodolfo-Rubens, kB11, iivo_k and 8 others like this.
  3. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    Thanks for explaining the outline, it is very interesting, but what about blurry text?
     
  4. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Are you looking to blur the text or to not having it appear blurry. TextMesh Pro can do both by using the Softness control. Unless you add softness, the text will always render cleanly and sharp at all point size and zoom.
     
    Rasly2 likes this.
  5. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    That is what i wanted to hear. It there realy no alternative to Text Mesh Pro?
     
  6. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,473
    Well now you're just making it look like Unity ui.text and its font effects was developed by an intern..

    How much would Unity Technologies have to pay you to include this in Unity natively, they could really do with someone like you to add better built in improvements.

    Also the font fallback support you added recently looks like the problem of multi language support is covered now, though it does look like some extra ground work is still needed to manually add extra fonts to cover those languages.
     
  7. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The developers at Unity are all amazing folks. It's just that text in pretty much all game engines is an afterthought.

    A lot more could be done with a closer integration. The folks at Unity know how to get a hold of me if there is any interest.

    The addition of the Multi Font & Sprites support along with Font Fallback opens up a lot of possibilities not only in terms of multi language support but also the ability to use fonts with icons like Font Awesome. See the following example.

     
    Last edited: Mar 4, 2016
  8. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here an example showing how the material properties can be tweaked dynamically to achieve different visual styles for the text.


    GIF - Animation so please forgive the compression artifacts.

    Once you are satisfied with a particular look, you can create a Material Preset using the added material context menu. Those Material Presets can then assigned it to any text objects using the same font asset.

    Typically for larger text on screen like titles where the text is more heavily stylized, you end up with more presets whereas for smaller text, I usually only create a preset with an Outline and another with Outline and Soft Shadow.
     
    Last edited: Mar 12, 2016
  9. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,473
    some of your images are linked to some walled up google link you need to login for...
     
  10. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thank you for letting me know. I have updated the images and hopefully you can see all of them now.
     
  11. Alex Storm

    Alex Storm

    Joined:
    Jul 21, 2014
    Posts:
    11
    Been using TextMeshPro for the better part of a year now and when it comes to text, I simply could not live without it.

    All the images appear fine to me.
     
  12. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    249
    TextMeshPro for president!

    In all seriousness though, text mesh pro is miles ahead the best text asset for unity, the default tools aren't even in the same league. The only real use case where TextMeshPro doesn't really work at is loading fonts not built into the project.
     
    Yukichu, Stephan-B and Not_Sure like this.
  13. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,650
    Yep, TMP is easily one of my five "must have" assets.

    And, as Stephan just demonstrated, the support is PHENOMINAL.
     
    Yukichu and Stephan-B like this.
  14. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    Awesome nickname.

    Looks like i have to buy this then, dont need it right now so ill put it on my watch list for some time, maybe there will be a discount on it.
     
  15. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thanks for adding TextMesh Pro to your wishlist.

    In terms of pricing, the current price reflects a 30% discount since the product is still labeled as beta. Once version 1.0 is released, the 30% beta discount will go away and the new price will be between $90 and $95. The last two major remaining features on my 1.0 list were the Multi Font & Sprites which is now available and the Text Input Field which I am currently working on. Once this new feature is available, I'll give a 30 day heads up to everyone and then finally release version 1.0.

    After version 1.0 has been released, the product will go on sale from time to time but the discount and price will never go below the current $65.00 as I feel those who purchased my product when it was first released as beta and had no reviews and thus took the greatest risk deserve my gratitude and to have paid the lowest price for my product.
     
    hippocoder and Yukichu like this.
  16. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    6,497
    Is there an estimated time for it to come out of beta? I mostly ask because I can't afford it until the end of the month
     
  17. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I am hoping to get this last remaining feature on my 1.0 list released within the next 30 to 60 days. I just need to keep resisting the urge to keep adding more features in between. ;) So you'll be fine thru the end of the month.
     
  18. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,650
    Trust me guys, 100% worth it.
     
    Teila likes this.
  19. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Not_Sure for Campaign Manager or at a minimum Forum Evangelist :)

    All joking aside, I keep showing all the pretty stuff but even when using plain text, TextMesh Pro provide full control over Character, Line and Paragraph spacing, Kerning. It also features over 30 rich text tags that provide much greater control over text formatting. Here's a few of those rich text tags. See the list of tags here.

    TextMesh Pro - Rich Text Tag (Basic).jpg
    Then you have tags like <align> which make it possible to control alignment within a single text object.

    TextMesh Pro - Rich Text Tag (Align).png


    TextMesh Pro - Rich Text Tag (Margin).png

    Then you have things like the <style="style name"> tag which provides for the ability to combine these tags sort of like CSS style tags. Then you also have a <link> tag to make it possible to embed links into your text. Here is an example where the link tag is used but also shows an example of the <style> tag used to define a link tag.

    TextMesh Pro - Rich Text Tag (Style).png

    Here is a video showing how you can interact with the text as well.



    Like I said, even if all you use is plain text, TextMesh Pro provides a lot more functionality when it comes to working with text.
     
    Last edited: Mar 22, 2016
    Kemonono likes this.
  20. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    You should stop usign that image service, half of those images are not showing.

    Can you show how your asset renders small text on overlay canvas?
     
  21. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I am using Google Photos and had fixed all of those images but they appear to be gone again. Argh! (Fixing these again)

    Here is an example using a Canvas in Screenspace overlay using (top) 14 point size and (bottom) 24 points.

    upload_2016-3-12_14-58-42.png
    Hinted smooth was used for both TMP & UI.Text Bitmap

    Rendering text at small point sizes like 10 - 16 pts. is challenging simply due to the fact that you don't have many pixels to work with to accurately represent the shape of potentially complex characters. This is why when using Bitmap fonts, you have to raster the characters for each of those specific sizes using techniques like Hinting which alters the shape of the characters to improve the rendering. Basically you want to render those bitmap textures at 1:1 to avoid scaling.

    Best rendering results at small sizes will be achieved using bitmap fonts rendered using hinting for those specific sizes. If you were to examine the font atlas texture for UI.Text, you would notice the bitmap contains a representation of each letter for each point size and for each style like bold or italics used.

    Having said all of that, as you can see in the image above, the SDF Font Asset (text) even at 14 points still renders nicely but unlike the bitmap fonts, the SDF Font Asset only needs one representation of each character to render the text cleanly at any point size, resolution and zoom factor. In addition, as a benefit of using TextMesh Pro SDF Font Assets, you gain the ability to dynamically style the text to add outlines, shadows, dilation, bevel, textures, etc... all using the same SDF Font Asset and by creating Material Presets, you can easily recall those visual styles.

    So if a project was to only use small text (ie. plain text since adding outlines and shadow on small text can actually make it harder to read), using TextMesh Pro with bitmap font assets would work best for small text. However, as soon as the text gets larger (16 pts (ish) and up) the benefits of using SDF text rendering become significant and provide much more flexibility.

    Here is an example of such dynamic styling where all I am doing is tweaking material properties.


    Here is an example of the same font asset where I have assigned different Material Presets to the letter S.
    TextMesh Pro - Unlimited Visual Styles II.png

    Hopefully, this provides you with the information you were looking for. Let me know if you have any other questions.

    P.S. Hopefully the images are showing up this time :eek:
     
    Last edited: Mar 12, 2016
    Rasly2 likes this.
  22. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    It surely helps, thanks. Perfect for me would be if would be able to recreate such great font effects as in HotS game.
     
    Last edited: Mar 13, 2016
  23. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Do you have any specific example of those effects from HotS?
     
  24. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    Sure, here:
     
  25. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Since Blizzard is using a commercial licensed font, I can't match the font exactly. Since their font is narrower as well as thinner, I had to dilate the font which isn't ideal. If I had access to the same font, I am confident I could make the two look identical.

    Here is an example using similar fonts.
    upload_2016-3-14_16-12-45.png

    Just for fun, I tweaked the "Venture Underground" to add a blue glow and reduced dilation on the smaller text.
    upload_2016-3-14_16-45-15.png
     
    Last edited: Mar 14, 2016
    Rasly2 likes this.
  26. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    419
    I'm going to write-in TMP for my presidential candidate tomorrow. Seriously one of the few absolute must-have assets.
     
    Teila likes this.
  27. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,775
    TextMeshPro is the best thing ever. Honestly, there is nothing that comes close in the 3d engine rendered text arena to his approach, and his asset is absolutely top tier.

    The way that text rendering works in a 3d engine is sort of a unique beast and it's not remotely like how text is normally rendered. If you're coming from a graphic design background it will all seem very counter intuitive and annoying.

    TMP is really the best that you'll find.
     
    Last edited: Mar 18, 2016
    Stephan-B likes this.
  28. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thank you for the kind words @frosted
     
  29. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    Would you ever release an asset that would let people use same material effects on other ui graphics, not just text? I think it would be popular.
     
  30. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    It has been suggested several times and I certainly agree and see the benefits of such a tool.

    I just need to find the time or hire someone to help me out. There are still tons of features that I want to add to TextMesh Pro and so little time for anything else.
     
  31. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,289
    Agreed. There should be no doubt on this.
    Text in Unity = Text Mesh Pro.
     
    Stephan-B and hippocoder like this.
  32. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,075
    IMHO it's better than any native engine integration I've seen in any engine. For me it's simply - this is what you use for text. Some people hate spending money, in which case it's natural to settle for the built in.
     
    Yukichu, Stephan-B and Ryiah like this.
  33. MattMurphy

    MattMurphy

    Joined:
    Dec 24, 2013
    Posts:
    111
    I'd like to echo other positive comments here- been using TMP for a while now, it's just superior to the in built text, and it's super easy to use.
     
    Stephan-B likes this.
  34. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,013
    As much as I like Text Mesh Pro, I stopped using it as it broke every time a new Unity version was released. Also there were little issues randomly like the text would sometimes stop displaying.

    Yes I could of contacted the developer and tried to sort it out, but I have a game to make and time is something I'm short of at the moment. So what I did was go back to the standard text but set my initial display to 1920x1080 in the canvas scaler and my text seems fine.

    I plan on trying Text Mesh Pro again once it's out of beta and I have more time.
     
  35. Rasly2

    Rasly2

    Joined:
    Feb 19, 2015
    Posts:
    211
    Well for the sake of diversity. Has anyone had any experience with UI Text Effects (https://www.assetstore.unity3d.com/en/#!/content/52508)? It seems to have its own text rendering like TMP but not as many effects and it seems to be much more lightwight. I would like to hear some details from someone who used it.
     
  36. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I am sorry that you had some issues when upgrading to new Unity releases. Unfortunately despite my best effort, when Unity makes changes to their API which can be dramatic in the case of Unity 5.2 for instance, there is nothing I or any Asset Store Publishers can do to prevent these issues. All we can do as Asset Store Publishers is to be responsive to the needs of our users and release updated versions of our assets, designed to work with these new versions of Unity as soon as possible.

    Unless users contact me to inform me of potential issues, there is very little I can do to help them. Although some issues may take longer to resolve especially if it is hard to reproduce or if I am waiting on Unity for something but in many cases, I can resolve these issues within hours or the same day.

    So please do reach out to me when you have issues as I will certainly do everything in my power to get you back up and running as soon as possible.
     
    Last edited: Apr 4, 2016
    frosted likes this.
  37. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,791
    I love Text Mesh Pro! It is not hard to learn, although takes a little dedication, and the results are amazing. :) One of my best purchases and one I will use many times. Text can make a huge difference in the professionalism of your product and some investment into a good text asset is worth it.

    The updates sound wonderful!
     
    Stephan-B likes this.
  38. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,650
    It seems really unfair to have issues with a product and not bother telling the dev, but then take the time to complain about it on a thread.

    How can you fix something that you don't know is broken?

    I mean, it's programming, not magic.
     
    Teila likes this.
  39. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    312
    TextMesh Pro is the baseline for text rendering in Unity. For a hobby project it's expensive, sure, but if you actually need to show any significant amount of text in a serious project, then there are no options. I remember Unity mentioning SDF text rendering for the new UI in the pre-release ads, but they couldn't pull it off and it's no longer even on the roadmap. Many popular assets are of horrible quality especially to someone who can't stand unnecessary runtime allocations (looking at you, iTween), but this one is really well made.

    Any issues I've had have always been resolved quickly and I almost feel bad reporting them on the forums from my EU time zone since the dev is usually there replying at 3 AM their local time. :p They've also been very helpful whenever I need to make custom changes to the code for some very specific use cases, but with the latest versions I've been able to ditch pretty much all of the custom code since the stuff is now built in.
     
    mh114, Yukichu, Teila and 1 other person like this.
  40. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,013
    Thanks, like I said, I'll try it again once i have more time and when it's out of Beta.

    I'm not complaining about them, I'm just offering my experiences.
     
  41. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Appreciated and like I said, be sure to reach out to me should you have any issues as most of the time, I can get you back up an running pretty quickly.

    Keep in mind that being out of beta won't change the fact that when Unity releases a new version which contains API changes which directly affect my product, you will need to update to a newer release of TextMesh Pro. This isn't specific to my product as it would affect all other assets and even your own scripts that would have been using those API.
     
    derkoi likes this.
  42. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    As requested by a few users, I added support for Soft and Hard Hyphenation today. The Green text contains Soft Hyphens "\u00AD" whereas the Yellow text contains a Hard Hyphen "-". This new functionality works with all text alignment options including Justified.



    This will be available in the next release of TextMesh Pro.
     
    zombiegorilla likes this.
  43. Stephan-B

    Stephan-B

    Unity Technologies

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



    This works with word wrapping, Multi Font & Sprites, Fallback font system and other text formatting options and rich text tags.