Search Unity

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
    This looks like one of those random Unity Editor error / bugs which I occasionally run into. This can happen on any objects when selecting the object in the inspector. I keep hoping someone will eventually submit a bug report on it as this is pretty illusive in terms of what causes it to happen.

    I would suggest closing Unity and re-opening the scene. If the problem does persist, then please email me a repro as you might have stumble upon something new. These are all Unity internal errors but being to Repro them is key to getting Unity to fix them.
     
  2. inxidious

    inxidious

    Joined:
    Nov 8, 2013
    Posts:
    22
    Hi Stephan,

    Can i retrieve a sprite that is used in a Sprite Asset, to place it in a SpriteRenderer?
    If i'm using resources.load separately for my sprite atlas, i'm afraid that unity would load it twice, I've been using this approach for a couple of weeks, but now it stopped working. The sprite loaded successfully in a TextMesh text, but missing in my SpriteRenderers. Any suggestion?
     
  3. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The Sprite in the Unity sense is an image set as type sprite (single or multiple) which Unity when resources are loaded reads to make parts of this image sprites. So this resource is only loaded once.

    The Sprite Asset is a data structure which contains information about the position of the sprites and references an image which contains these sprites. TMP doesn't even need this image to be set as sprites which assuming you were not using those sprites with the Sprite Renderer would add additional overhead.

    In terms of why this referenced images set as type Sprite doesn't work with the Sprite Renderer, I am not certain. Check to make sure it is of the correct image type.
     
  4. inxidious

    inxidious

    Joined:
    Nov 8, 2013
    Posts:
    22
    Thanks for the explanations,

    TMP loads the sprite asset when scene loads right?
    I need to use the same sprite texture for texts and SpriteRenderers (e.g. coin and gem which i use in a text and 2d Sprite,
    so, is there any functions like:
    public static Sprite TMPro.GetSpriteFromSpriteAsset(int index) ?
     
  5. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The default sprite asset (assigned in the TMP Settings file) would get loaded the first time it is accessed. If the sprite is referenced in some text object, using something like <sprite="Sprite Asset Name"> then it would get loaded the first time this is encountered.

    Having said all of that, you should not have to do anything to access those sprite outside of TMP. If you have a sprite sheet (image where you have defined the sprite in the Unity Sprite Editor), those will be loaded by Unity automatically.

    TMP doesn't load those sprites individually. When it comes time to draw a given sprite, TMP simply looks at the texture and UV coordinates. TMP doesn't even need this png / texture to be of the type sprite at all. The TMP Sprite Asset basically contains the data (UV coordinates, etc.) to allow TMP to know where they are in the texture and how they fit relative to the text.
     
  6. lovexiawenzhen

    lovexiawenzhen

    Joined:
    Jul 14, 2015
    Posts:
    3
    Hi Stephan,
    I want to know How to open the text mip map,Because I am in VR Text will be Twinkle.Or do you have a better solution in VR?
     
  7. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    If you are using SDF Font Assets, the text should render nicely in VR as well.

    Mip Mapping isn't applicable to SDF text rendering.
     
  8. DenisTilak

    DenisTilak

    Joined:
    Jan 11, 2017
    Posts:
    3
    Hi, is there a way to set a text at a specific "real" size with TextMeshPro ?
    For example if I want my text to be 1cm high, no matter screen resolution/dpi/device real size.
    Thanks.
     
  9. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I guess you could calculate what point size you need to use by checking the pixel height of the font from Ascender to Descender based on the sampling point size which is information available in the font asset editor and thru the API and then based on resolution used / camera settings / canvas scaler computer the point size you need to use to get to that 1 cm height.
     
  10. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    Does your asset support text that is affected by world lighting? I'm using Unity's text with one of their light ui shaders, which works great if the light is facing the text, but otherwise the text is black. Basically I want text that is lighted based on ambient lighting instead of directional lighting. I also need it to be affect by shadows and so on in the scene though, so if the text is under a shadow it should be less visible then if it was out in regular daylight.
     
  11. mopsicus

    mopsicus

    Joined:
    Feb 15, 2016
    Posts:
    13
    Hi Stephan!

    Today I've bought this super asset. And, I expected to find in it emoji support, but it doesn't have. I got it just for that function. So, what I should to do?
     
  12. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The release available on the TMP user forum does have a basic implementation with support for Emoji. See the following thread http://digitalnativestudios.com/forum/index.php?topic=753.msg10040#msg10040

    I still need to add support for Emoji modifiers and variants and will be making tweaks as we go forward.
     
  13. mopsicus

    mopsicus

    Joined:
    Feb 15, 2016
    Posts:
    13
    Thx, I'll try it.
    Can I set unicode label to each sprite by script or smth else, If I want create sprite asset with all emojies? cuz do it manually for 1500+ emojies is really terrible :(
     
  14. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    As per the post / thread I linked in my previous post, the latest release of TMP available on the user forum has a new feature where you can create a TMP Sprite Asset from Texture Packer using Json Array export where the unicode values will be automatically assigned to the sprites.
     
  15. mopsicus

    mopsicus

    Joined:
    Feb 15, 2016
    Posts:
    13
    Ok, I've made new sprite asset by TexturePacker and Sprite Importer. But! When I testing unicode emoji sign, like "test emoji \U0001F0CF", I see different emojies. It should be joker card, but I see some smile. I guess, json file was generated wrong. Maybe you make video or text manual, how to add fully emoji support in text mesh pro?
     
  16. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    You need to use JSON Array with Texture Packer.

    The name of the sprite is what it ends up using to assign the unicode value. To check this, select the Sprite Asset to see what value is assigned to this \U0001F0CF sprite.

    I would suggest you register on the TMP user forum and create a separate post where we can communicate / share information more easily. (ie. not have additional posts in between on other topics).

    In terms of a video, I'll create one as soon as I have some extra time.
     
  17. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    @Stephan-B

    Is there a public function/variable anywhere in TMP to return the text that is being displayed in a TMP component after all the tags have been stripped out?

    Thanks!
     
  18. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    There is no function to return this information although one could easily be added.

    Once the text has been rendered. To get the information you can iterate over the TextMeshPro.textInfo.characterInfo[index].character. The index would be the number of characters which is contained in textInfo.characterCount.
     
    flashframe likes this.
  19. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    Thanks Stephan :)
     
  20. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I'll add the new function since this has been requested a few times.

    Like I said, it is easy to implement given the underlying information is already available from the TextMeshPro.textInfo data structure.
     
  21. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    Yep, I've just added it to the script I need it in. Happy with that, cheers.
     
  22. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    Thanks, I'll subscribe soon :)

    I have an issue tho.
    Several frames after Start, I try to access the textInfo to update the text on a TextMeshProUGUI component, but doesn't update!

    Code (CSharp):
    1.     public virtual void SetPage(int pageNumber)
    2.     {
    3.         currentPage = pageNumber;
    4.         textBox.pageToDisplay = pageNumber;
    5.        
    6.         pageNumbersBox.text = string.Format(pageNumbersStringFormat, currentPage, textBox.textInfo.pageCount);
    7.         //pageNumbersBox.ForceMeshUpdate();
    8.     }
    For some reason tho, if I press the Next and Previous button, that only decrement or increment the currentPage, the text "1 of 19" gets updated.

    I tried to force an update but didn't work.

    Am I missing something?

    Why is this not working?
     
  23. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    It is hard to tell what might be going on. Do you have Overflow Page Mode selected on the text object?

    Give the following Page Mode Demo package a try a see if it behaves as expected.

    If you can't sort this out, please send me an email with a private link to a Repro and I'll be more than happy to take a look to figure out why you are getting the behavior that you are reporting and hopefully shed some light on this.
     

    Attached Files:

    Last edited: Jan 28, 2017
    NeatWolf likes this.
  24. v3_matt

    v3_matt

    Joined:
    Aug 10, 2015
    Posts:
    8
    @Stephan-B I am having a layout issue with TextMeshPro. We are using the Unity ContentSizeFitter to make scrollable text boxes. However, this sometimes doesn't work properly. I occasionally get a result where the text is 2 or 3 lines longer than the rect.

    This is the bottom of the rect, fully scrolled-down.
    BottomOfRect.png

    I have the scrollbox set as elastic, so I can force the scrollbox past the bottom to see the last two lines.
    BottomOfRect_Elastic.PNG

    My only option right now is to add a big margin to the bottom. But this causes the scrollbar to show up even when there's not additional text.

    I should point out that I can get it to "work" in the editor by changing the margin-bottom value in the tmpro editor. This must force some kind of refresh.
     
    Last edited: Jan 31, 2017
  25. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This should be working correctly so let's figure what Gremlins are causing this behavior on your end :)

    Can you provide me (via email or post on the TMP user forum) with a Repro Scene of this so I can take a look?
     
  26. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    any updates for unity 5.6? I can't use textmesh there when upgrading
     
  27. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I spoke with Unity two days ago and they expect to have a fix for the cryptic "Transform has SetIsDispatchInterested present when destroying the hierarchy. Systems must deregister themselves in Deactivate." either in the next beta or the one after it.

    I uncovered additional issues in the latest Unity 5.6 Beta 5 which Unity is also aware of which they will address as well.

    There are some new warnings in Beta 5 resulting from some functions in the Handles class being deprecated which I can address on my end.

    However, as for the rest of the issues, we will have to wait for Unity to address / fix those as they are on their end of things.
     
  28. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    Is it possible to use text as a mask to reveal your game beneath? Similar to stranger things intro or various other 80's effects with the text cutting holes in a black overlay.

    Thanks.
     
  29. Matt-Roper

    Matt-Roper

    <Of The Graphics> Unity Technologies

    Joined:
    Oct 27, 2015
    Posts:
    106
    Hey,

    Quick question, does Textmesh have a maximum character limit like Unity's text component?

    Cheers
     
  30. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    It does not. When the vertices limit is reached, TextMesh Pro will split the remaining characters into a sub text object which is how it also handles sprites and multi fonts.

    Note that although TextMesh Pro gets around this limitation, I still believe it is more efficient to figure out some logical way to split your text into smaller blocks especially given you can't really display that many characters on a single page / screen anyway. So although I have users who rely on this functionality, try to split your text objects into smaller ones if you can.

    It is also important to note that Unity's EditorGUI and related classes / functions like TextArea which are used in the Editor / Inspector do have the 65,535 vertices limit. So in the editor, you can still get errors but not in builds / run time.

    Feel free to PM me if you need more information about any of this.

    ** Update **
    Here is an example I just created using the Unity Terms of Service agreement which contains 24,206 characters or 96,824 vertices.

     
    Last edited: Feb 12, 2017
    Matt-Roper likes this.
  31. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    In this example, because TMP is doing the splitting, is everything still considered one block or is it still several boxes? For example, if I were trying to get textinfo.linenum and wanted the very last line, would I have to figure out what box it's in from TMP's split or if I just targetted the one "box" does it allow me to find the last line?
     
  32. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    From a user point of view, it is just one text object. So regardless of the text getting split into several sub text objects for sprites, multiple fonts, materials or because the text exceeds the 65k limit, the textInfo and everything else is that of a single text object.

    The only part to be aware which is related to multi font mostly is that textInfo.meshInfo[materialIndex] is an array that contains the geometry of the primary and sub text objects. Each textInfo.characterInfo[index].materialIndex indicates which meshInfo index is used by that character. The Animating Vertex Attribute example scene and script shows how this is used.
     
  33. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Ok, this was what I was interested in. If we let TMP handle it and it requires 3 boxes worth, it's one textinfo. If we split it ourselves into say...3 boxes, we now have 3 textinfo, thus creating a situation where we must handle figuring out which box we're over ourselves.

    Good to know!
     
  34. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here is a potential improvement to "Justified" text alignment.

    On the left is the current implementation. On the right is the alternative which still provides control over blending of word and character spacing.

     
  35. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Here is another slight potential improvement which limits how much the word spacing can shrink or increase.

     
  36. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Hi there, I'm looking for a fade in out effect for my text or typewriter effect. Is there any for TextMesh pro?
     
  37. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Yes. Example "10 - Old Computer Terminal' included with TextMesh Pro is an example of a Typewriter style FX. Here is an example gif animation of this



    There is also another example and script available on the TextMesh Pro user forum which does a different type of Fade / Reveal. See the following thread. Below is an example of this alternative FX.

     
  38. Tivec

    Tivec

    Joined:
    Jun 20, 2015
    Posts:
    13
    Hey, I'm seeing some weird distortion in my textmesh. The text is on a screen space overlay canvas on my screen, and there's sometimes weird lines in the numbers as seen on the 0 in the "U:" string on this screenshot:

    Screenshot taken from the editor (at slightly different numbers, but the distortion was present in the game scene as well):


    Here's the inspector for the textmesh: http://i.imgur.com/4O3TdMo.png

    Any thought what could cause this?

    Edit: After a bit of testing and tearing my hair out, I rescaled the game window by ever so slightly, and it seems to be looking much better now. The distortion is still there, but it is not as bad.
     
    Last edited: Feb 24, 2017
  39. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This might be the result of the fact the text (font design) has some pretty narrow parts. Make sure you enable Extra Padding in the text object inspector.

    In addition, is the font you are using the one that was included with TMP or a re-generated one? Make sure the padding value is greater than 5 (otherwise extra padding won't have enough room for the extra padding) and that your ratio between Sampling Point Size and Padding is about 10%. See FAQ Question 1 and 11 on the TMP user forum as well as the Font Asset Creation video which explains the importance of this.

    Make sure you are also up to speed on Material Presets as they are important to understand.
     
  40. Tivec

    Tivec

    Joined:
    Jun 20, 2015
    Posts:
    13
    I use the default font that was included, I haven't had a chance to generate one myself yet. I'll give the padding a look though, and see if that solves the issue for me, and then to the FAQs and video I go :)
     
  41. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The padding in the LiberationSans should be fine but enabling Extra Padding should help.
     
  42. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
  43. zyzyx

    zyzyx

    Joined:
    Jul 9, 2012
    Posts:
    227
  44. imgumby

    imgumby

    Joined:
    Nov 26, 2015
    Posts:
    122
    Yeah congrats...a bit upset that I paid nearly $100 for this and now it's free to the masses but se la vie...o_O
     
    movra, hopeful and derkoi like this.
  45. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Now that it's free....certainly no reason not to own it for the features. Nice.
     
  46. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Oh wow. Grats man. It really says something when your asset is so awesome Unity buys it. Smart move on their part, and I hope it continues to be improved!
     
    IgorAherne, adventurefan and hopeful like this.
  47. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Congratulations, indeed. Unity made a smart move here for sure.
     
    IgorAherne and Stephan-B like this.
  48. ThermodynamicsMakesMeHot

    ThermodynamicsMakesMeHot

    Joined:
    Feb 14, 2015
    Posts:
    224
    I see this as a bad thing...but time will tell. Who is going to support it? Doubtful there will be any effort to expand on this asset or add new features now. Sucks for the people who paid for it. I see this becoming just another junk asset like so many others. IMO this is bad. They will gut it take what they want then toss it to the side....anyone remember NGUI. And we know how awesome the unity UI is HAHA.
     
  49. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Yep, I remember. I tried it and it was a convoluted mess that was difficult to use. I think this is a good move. Unity needed a better text solution and this is the best.
     
    Stephan-B likes this.
  50. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Interesting that you were able to get away with this since the Unity owned version is a separate asset in the store.
     
Thread Status:
Not open for further replies.