Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta 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. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,519
    That is so well done.

    For example if you wanted to simulate a player shinning a flashlight across each letter (e.g. moving left to right) that would seem like it would be trivial via the appropriate scripting.
     
  2. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You could use the Surface Shader and shine a spotlight at the text as per this example.



    There is an example of this in the example scenes included with TextMesh Pro
     
  3. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Moving the TextMesh Pro Asset Folder
    In the event you might want to move the TextMesh Pro folder to a different location like "Assets/Plugins/TextMesh Pro/..." for instance, due to Unity's script compilation order, your will need to move the TextMesh Pro/Editor folder to "Assets/Plugins/Editor/...".

    Once the move is done, the hierarchy would look like this.
    Assets
    Plugins
    TextMesh Pro (TMPro folder)
    Editor (TMPro editor folder)
     
  4. 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.

     
  5. Nikola-B

    Nikola-B

    Joined:
    Jan 31, 2014
    Posts:
    42
    What is the difference between the <space> and <pos> tags and how are those different from tab?
     
  6. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    <space=2.0> will add 2 spaces after the tag. Space=1.0 is equal to the char(32) space width. Space can actually be a negative value.

    <pos=5.0> will position what follows the tag to about 5 spaces from the start of the line. <pos=0.0> moves the text back to the start of the line. <pos> can also be a negative value.

    \t or tab insert a tab which is defined as 5 spaces.
     
  7. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Quick news flash:
    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 :)
     
  8. Nikola-B

    Nikola-B

    Joined:
    Jan 31, 2014
    Posts:
    42
    I was playing with \t (tab) and it seemed more to behave like a tab stop as opposed to adding 5 spaces. I actually prefer the tab stop style but just curious about it now.
     
  9. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You are correct. The Tab(s) are tab stops which makes it easier to line up (tabulate) the text.
     
  10. 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.

     
  11. Nikola-B

    Nikola-B

    Joined:
    Jan 31, 2014
    Posts:
    42
    How did you get the texture to span across all the letter?
     
    Last edited: Jul 6, 2014
  12. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I am using UV Mapping Option set to Horizontal = Paragraph & Vertical = Line.

    Here is an example I posted before which shows the texture applied per line horizontally and per line vertically. Given this example is just one line, the results would be the same with paragraph horizontally and paragraph vertically.

     
  13. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,403
    Is there any chance of a version of the shader that has back face culling on and no shadow casting? Or is that there already and I have just missed it?
     
  14. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Which shader are you using. There are 4 SDF shaders with TextMesh Pro. The Distance Field & Distance Field Mobile shaders do not have shadows. Both Distance Field Surface & Distance Field Surface Mobile have shadows. Shadows can be disabled on the renderer or are you looking to disable the shadow caster completely and why?

    In terms of culling, I added a new property to control back face culling which will be included in the next version. Until then, you can change Cull Off in the shaders to Cull Back
     
  15. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,403
    Mmm very odd, I am using the non surface Distance Field shader but the text is casting shadows, image below. If I turn of cast shadows on the object the shadows turn off, but I need the shadows on for the object but not for the text that is part of the same object. You can see in the inspector that the shader is the non surface version.
    Chris
    tmproshadow1.jpg
     
  16. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    What happens when you comment out the fallback in that Shader? It might be using the fallback as the shadow caster.

    Change the fallback to this

    Fallback "TMPro/Mobile/Distance Field"
     
  17. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,403
    Seems the problem is the Distance Shader is too complex as it is using the fallback shader, and the fallback shader for 'Distance Field' is 'Mobile/Distance Field (Surface)
     
  18. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,403
    Arr we found the same thing at the same time :)
     
  19. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    It is not that it is too complex. If I recall Unity uses the Fallback as the shadow caster. The fallback should not be the surface version anyway.
     
  20. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    On a separate note, I am thinking the Drop Cap Tag which is on my TODO list should be a nice addition here. I don't see many folks using Drop Caps in the text for their games but in Books like your Asset does, I totally see it being pretty neat.
     
  21. 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.

     
  22. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,267
    So this is similar to NGUIs "ShrinkContent"-Feature, but with much more options, right?
    And it will come before Unity 4.6? If so, gonna buy the asset the moment the plugins gets updated with this feature :D
     
  23. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I do have some users using TextMesh Pro in conjunction with NGUI. They are simply replacing the label by a TextMesh Pro object. However, I would like to have a closer integration to use NGUI's equivalent of this TextContainer to control the text object.

    In terms of a time table for this new feature, I should have a Beta of this new TextContainer ready for my Beta testers this week. If all goes well, it should be available shortly thereafter in the Asset Store.

    Only Unity knows when 4.6 will be available.
     
  24. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,267
    Personally I don't need to replace NGUIs functionality, but to use Text Mesh PRO ingame. I'm working with 2D Toolkits TextMesh System for now, but the lack of such an Auto-Size/Shrink Content-Feature makes it a little bit difficult to get text and localisation right, since I want to fit the text in a certain box/container, regardless of the language.
     
  25. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    TextMesh Pro was initially designed as a replacement for Text Mesh and then I kept adding features :) This new TextContainer was created to further improve control over the text / layout and should do what you need.

    I presume you watched the video, which shows the key functionality of that new Component.
     
  26. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,267
    Yep I did! And If I'm not mistaken you stated this functionality will be implemented when Unity 4.6 arrives :)
    But since you managed to do the job sooner, I'll get the asset as soon the update with that functionality hits the store!
     
  27. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I believe I was referring to when the new RectTransform implementation will be available.

    If all goes well with the testing, I am hoping to submit Beta 0.1.45 of Text Mesh Pro which will include this new TextContainer late this week or over the weekend :)
     
  28. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,267
    Alright, couldn't resist and bought it :p

    Don't know what I did. Just placed some TextMeshPro Objects in the scene and fooled around. And after some time I started to get these errors:

    I get these errors even when there's no TextMeshPro Object in the Scene.



    EDIT:

    Deleted the orginal TMP Folder, closed Unity, reimported. Errors still occur :/
     
  29. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Which version of Unity are you using?

    Is the text visible or are you getting pink rectangles?

    Did you create or move or change some material or their location (in the resource folder)? The Arial SDF material is assigned by default when creating a new object. if it has been moved or deleted, then no material is assigned which could result in those errors.

    *** Some troubleshooting

    Let's take it one step at a time and begin with an empty project in which you will import the TextMesh Pro Asset.

    Then from the Create menu in the Hierarchy window, create a new TextMesh Pro object. Let me know if those errors occur?
     
  30. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,267
    1. Text is visible, no pink rectangles.
    2. Didn't even look in the TextMeshPro Folder, so no moving/changing and no creating.

    Anyway...restarted my System. It seems the errors are gone...
    Don't know why and how, but when the Error was present everytime I created a TextMeshPro Object, I got a little blurry red-filled "Hello World!" with an black outline instead of a simple clean white "Hello World!"
    Now everythings fine again. I really didn't do anything besides creating TextMeshes in a scene and creating a simple script trying to change the .text field from the TextMeshPro-Component dynamically, but that couldn't do that weird stuff, right?
     
  31. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I am glad it is working now.

    I am not certain what might have causes these errors. m_renderer is a cached reference to the renderer and it is assigned in Awake() or whenever a new material is assigned. Somehow, that re-assigned or something got confused.

    Should this occur again, in the editor panel, change the font asset back to the Arial SDF which will force a re-assignment of material. What happens then might be telling.

    I would like to figure out what happens, just keep me posted if you run into this again.

    P.S. Take the time to register to the TextMeshPro User Forum which will make it easier for me to help out in the event I need to share files or something with you. Plus it will be beneficial to other users as well.
     
  32. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,267
    I'll keep you posted, yes!
    Gonna register right away!
     
  33. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Thanks :)

    BTW: I saw your registration to the TMPro forums. Welcome aboard.
     
  34. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Video Update #2 on the new TextContainer showing the various behaviors which you can expect from the TextContainer, text auto-sizing and other properties.



    I would love to get some feedback on these behaviors as I am trying to make sure they are as intuitive as possible.
     
  35. Nikola-B

    Nikola-B

    Joined:
    Jan 31, 2014
    Posts:
    42
    That new Text Container with the auto-sizing feature looks like it will be very useful. I believe in the video, you indicated that this functionality would also be available and work with Unity's new UGUI. Is that correct?
     
  36. glunity

    glunity

    Joined:
    Jun 19, 2014
    Posts:
    23
    Hi Steffan. Some questions.
    (sorry my bad english)
    1 - can use in runtime text ? input keyboard, by example.
    2 - each letter can be gameobject with force ? gravity and compatible with the asset "circulargravityforce"
    3 - imagine a sphere, I need place the text in the superfice sphere or other mesh superfice ?

    very interesting to me.

    Thanks Steffan !
    Best regards.
     
  37. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Yes. The same functionality will be available but instead of using the TextContainer, the TextMeshProUGUI Component will be using the new RectTransform which will be introduced in Unity 4.6.
     
  38. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,267
    I think it looks really good so far! But I have another suggestion:

    would you mind implementing the same "Click to expand"-Functionality for the Text Input Box and the Font Settings?
    Would be great :D
     
  39. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Yes. I can make those Collapsible.
     
  40. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This should do the trick. These changes will be in the next release which will be Beta 0.1.45.

     
  41. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Essentially all Text and Material properties are accessible via scripting and can be changed at runtime. TextMeshPro was designed with realtime use in mind and optimized as such.

    In terms of keyboard input which I presume means selecting & editing of text in the gameview window for instance, is currently not available. However that is a feature that I am planning on adding. As a matter of fact, if you take a look at this old video, it shows an early prototype of TextMesh Pro which actually had text editing in the gameview. I removed that functionality at some point to focus on the core features first.


    Each TextMesh Pro object is a gameobject and as such you could attach a collider and Rigidbody which would result in the object reacting to forces & collisions. Essentially, you could have several Text objects comprised of a single letter with colliders and all reacting to stuff in the scene.

    The mesh of the TextMeshPro objects is available via the API and as such, you could write a script to modify / deform these mesh to map them onto other shapes. Since each letter is a quad, you might need to tessellate those to map them nicely on spheres and all but there are also other assets that do these types of things like Chris West's Mega-Fiers.
     
  42. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This for the fun of it and related to Question #2 of the previous post ;)

    This is basically the Surface Shader demo scene with an added twist. Keep in mind this is an animated gif so the quality of the video isn't great but "you get the idea".

     
  43. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Improved Line Spacing Tracking
    I have revised how line spacing is handled when the <size=+x.xx> is used. This revised behavior is consistent with how MS Word or other text layout tools handle line spacing with character of different sizes.

    Here is an image of the input text


    and the resulting text output


    And another example


     
  44. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Corrected a minor issue with how to line spacing was adjusted when using the <size> tag.



    Text Input is : "Example of some lines of <size=+16><#ffff80>text</color></size> for testing the improved <size=+8><#ffff80><size></color></size> tag and line spacing."
     
  45. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269


    To Unity on winning the 2014 Develop Award for Best Game Engine.


    P.S. Image was obviously created using Text Mesh Pro. Impact font with some Outline, Bevel, Glow, Face Texture and Underlay for the shadow.
     
  46. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Korean Character Set - All 11172 of them. Despite the sheer quantity of characters, the resulting point size (sampling) was 33 points which isn't too bad.



    Then using Google Translate (no idea if it did a good job or not) I used "Press play to start the game" which it translated to this

    게임을 시작하기를 눌러 플레이

    I then selected this newly created Korean font asset and pasted this text in TMPro's Text Input which produced the text (image) below



    From there I can modify TMPro's shader properties to apply treatments to this asset.



    BTW: It took less than 5 minutes to generate the SDF Asset shown above using TMPro's built-in Font Asset Creator.
     
  47. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Preview #2 - TextMesh Pro UGUI & Unity 4.6
    Here is another preview of the new TextMesh Pro UGUI component which will be available when Unity 4.6 is released. In this video, you can see the improved text auto-sizing feature along with some of the masking capabilities.

    This new component will be available as an alternative to the new Text component that is part of Unity 4.6.

     
  48. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    • Uncovered an issue with the new implementation of the size tag where line spacing wasn't adjusted correctly when Word Wrapping was enabled. This new functionality / behavior will be included in the next release.


    Please note this is a single text object simply using different size and color tags.
     
  49. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Size Tag & Line Spacing + TextMesh Pro UGUI component for Unity 4.6
    Demonstration of the revised implementation of the <size> tag along with text auto-sizing running in Unity 4.6 and rendering to the Canvas Renderer.



    A new size tag variant was added which is <size=%100> which allows that sized characters / words to remain sized proportionally to the baseline font size.
     
  50. Nikola-B

    Nikola-B

    Joined:
    Jan 31, 2014
    Posts:
    42
    Having the ability to specify a % percentage is a very nice addition.
     
Thread Status:
Not open for further replies.
unityunity