Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro Version 1.4.1-Preview 1 with Dynamic SDF for Unity 2018.3 now available!

Discussion in 'UGUI & TextMesh Pro' started by Stephan_B, Jan 31, 2019.

  1. subject_7

    subject_7

    Joined:
    Apr 9, 2019
    Posts:
    1
    Hello Stephan_B, when I did this, I got the following error:


    C:/Your/Project/Folder//2D Projects/Game - Copy/Library/PackageCache/com.unity.textmeshpro@1.4.0/Scripts/Runtime/TMP_InputField.cs(1682,152): error CS1644: Feature `out variable declaration' cannot be used because it is not part of the C# 4.0 language specification

    Do you have any idea of what it could be?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The Net 3.5 has been deprecated so you need to switch to .Net 4.x as seen in the image below.

    upload_2019-4-8_20-31-12.png
     
    bb8_1 likes this.
  3. Ecnassianer

    Ecnassianer

    Joined:
    Sep 1, 2015
    Posts:
    5
    I'm using dynamic fonts as a fallback for any characters that aren't in our localized text.

    When we're working in the editor, we often put sample text into our text fields to test layouts. Sometimes this includes characters that aren't part of our localized text, so those get dynamically rendered into our dynamic fallbacks. Great! We can test that just the way it would work at runtime!

    Unfortunately, Unity saves out the dynamic font atlas, and now there are a bunch of characters we don't intend to use taking up space in our dynamic atlas. This confuses people when they see it in source control, and they aren't sure if they should check in these changes to fonts or not. (There's also some slim legal risk of unknowingly shipping an ESRB rating or trademark violation in our game assets.)

    It would be really great if dynamic fonts didn't actually save their changes when running in the editor. Or at least have an option to disable that for specific font assets. I really only want to be writing to them at runtime.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I'll take a look at adding such option.

    Just so you know, you can always Reset a font asset by going to the Font Asset Context Menu and selecting Reset which will clear out all of the character and glyph content and zero out the atlas textures.
     
    v-ercart likes this.
  5. v-ercart

    v-ercart

    Joined:
    Apr 25, 2018
    Posts:
    8
    I've had to reset them a few times after they got checked in by someone else. I tried to use the Reset like you did in the video, but it doesn't work for me. I've been using the... I forget the label, it's something like "Regenerate Character Atlas" button or whatever that's in the inspector. Then I delete the characters there and regenerate. Same result, it's just a few more clicks.

    Even with these little bumps, the dynamic fonts are great! They're a huge save for us. All our fonts have dynamic fallbacks now. It would be cool if there was a button you could click in a font that makes a dynamic fallback and hooks it up with compatible settings to the font you're looking at. Thanks for making the dynamic generation work just in time for our project!
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I would like to know more about this as I use this option all the time which has been working as expected.

    When using Reset, you have to keep in mind that any text object in the scene using this font asset will get a callback and as such whatever characters they are using will end up right back into the font asset / atlas texture. This happens instantly so it makes it appear as if Reset isn't working when it actually is.

    Code (csharp):
    1. public void ClearFontAssetData(bool setAtlasSizeToZero = false)
    Can be called via scripting to clear any font asset.

    Better than that potentially is Font Assets supporting multiple atlas textures where these additional textures are created as needed. So when the potential fallback would have been using the same font file, the ability to use multiple atlas textures will be great (ie. no more fallback needed for those). You will still use a Fallback when you are using a different font because the primary font asset is missing certain glyphs or language coverage. Fallbacks which are Font Assets will of course have the ability to use multiple atlas textures as well.

    I need to create a video showing this new feature which will be available in version 1.4.2 and 2.0.2.
     
  7. BenjaminBachman

    BenjaminBachman

    Joined:
    Feb 1, 2017
    Posts:
    29
    I am having the same problem after updating to 2019.1. How exactly did you resolve it?
    I have tried deleting the cache folders, doing a "git clean -dfx" and removing and re-adding TMP from the package manager. But the error is still there.
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There is both a global package cache and the local package cache in the project's Library folder. Both should be deleted.

    P.S. I am not sure what leads to these seemingly random assembly compilation errors. Did you have any scenes open when you did the upgrade?
     
  9. bb8_1

    bb8_1

    Joined:
    Jan 20, 2019
    Posts:
    100
    Thx this worked for me :)
     
  10. Ecnassianer

    Ecnassianer

    Joined:
    Sep 1, 2015
    Posts:
    5
    I'm pretty sure I don't have any text objects in my test scene, they're all generated from prefabs spawned at runtime, but I will keep an eye on this and see if I can get you anymore clues.

    Nice, if this becomes more of a hassle later on, I'll write some utility to clear them out when an asset saves or something.

    This sounds even better!
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Release 1.4.1-preview.1 is now available for Unity 2018.3 and release 2.0.1-preview.1 for Unity 2019.1.

    This is a minor release to address potential issues in the conversion of legacy font assets.

    Release 1.4.1 also reverts the requirement on switch the Scripting Runtime to support .Net 4.x. This requirement remains for the 2019.1 release. Since .Net 3.5 is deprecated in Unity 2018.3, I still recommend using the newer .Net 4.x but reverting the change will spare users still running on the old Scripting Runtime from seeing 66 Error messages :)

    Since the above releases were to address the above issues, the intended version 1.4.1 and its included features and fixes will now be version 1.4.2 and 2.0.2 which should come within the next 10 - 14 days.
     
    bb8_1 likes this.
  12. PetrisPeper

    PetrisPeper

    Joined:
    Nov 10, 2017
    Posts:
    66
    What should we do if we get a spam of:
    The character used for Ellipsis is not available in font asset
    ?
    (I'm asking if we should regenerate it or something, if yes then what should we change?)
     
    Last edited: Apr 23, 2019
  13. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Disable Warning in the TMP Settings.

    And if you plan on using Underline or Ellipsis with that particular font asset, you should regenerate it to make sure it includes those two characters.
     
  14. DarkSunLcj

    DarkSunLcj

    Joined:
    May 30, 2018
    Posts:
    4
    Hello Stephan, when I use <nobr></nobr> tag in TMPUGUI Component for disable auto line breaking feature, it still break if there are space in text.Can I disable auto line breaking completely?Please tell me how to do,thank you very much!
     
  15. DarkSunLcj

    DarkSunLcj

    Joined:
    May 30, 2018
    Posts:
    4
    upload_2019-4-25_16-58-38.png upload_2019-4-25_16-58-51.png
     
  16. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    East Asian characters have their own line breaking rule which is what I suspect is interfering with the <nobr> tag.

    I'll take a look at this as soon as I have time and provide feedback thereafter.

    P.S. Since this thread is related to the migration of Legacy version of TMP to the Package Manager versions, please post questions / potential issues in the main Unity UI & TextMesh Pro thread as this will make it easier to track and find these posts / topics.
     
  17. OneManEscapePlan

    OneManEscapePlan

    Joined:
    Oct 14, 2015
    Posts:
    218
    Is there any written documentation about how to use the new Dynamic SDF features?

    It's not clear where even to start. If I go to Window > Text Mesh Pro > Font Asset Creator, there doesn't seem to be any options for dynamic SDF.

    If I select a TMP font asset I've previously created, I can see that there is an "Atlas Population Mode" field set to "static". However, when I try to change this to "dynamic", it doesn't change (the value remains "static").
     
  18. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Documentation is being worked on. Until then I suggest you watch the video in the first post of this thread as it covers the essentials of the Generation Settings.

    Most likely there is a debug log warning issued about the atlas texture of the legacy font asset not being read enable which would prevent switching to dynamic. See FAQ Question 2 in first post. Also note that when switching a legacy font asset to dynamic mode, you will also need to reset the font asset using the Context Menu (also covered in the video at 21:45).
     
  19. OneManEscapePlan

    OneManEscapePlan

    Joined:
    Oct 14, 2015
    Posts:
    218
    Thanks for the reply.

    Videos are not a good substitute for written documentation. You can't search a video for a keyword. You can't copy a particular passage from the video into your own files for reference. You have to watch the video in an environment where it's possible to hear the sound (and are totally out of luck if you're deaf). Even if you aren't done with the full documentation, a few more paragraphs in the initial post would go a long way.

    It turns out the source font file character mode was set to "Unicode" instead of dynamic. I missed the debug log warning because I almost always have to have the "warnings" level turned off, since Unity has traditionally spammed hundreds of irrelevant compiler warnings when opening or running a large project (e.g. 'field is never initialized' warnings for serialized fields which are actually assigned values in the inspector rather than in code). Although now that I'm paying attention, it looks like I'm not getting all of those compiler warnings in 2018.3.12f1, so maybe they fixed that.
     
    Last edited: Apr 26, 2019
  20. OneManEscapePlan

    OneManEscapePlan

    Joined:
    Oct 14, 2015
    Posts:
    218
    You don't mention in the FAQ how atlas size is handled for dynamic fonts. Say that we have a dynamic font with a 2048x2048 atlas. At runtime, the atlas fills up with CJK characters. Is the atlas automatically expanded to accommodate additional characters, or will new characters stop being added?
     
  21. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There is no resizing of Atlas textures other than the initial size of zero when they are created / reset.

    To handle the potential addition characters and glyphs, you should assign a dynamic fallback font asset of the with the same Ratio of Sampling point size to padding. So if the primary had a sampling point size of 90 with padding of 9 then the fallback could be something like 60 and 6 for the same ratio of 10%.

    Until the first glyph is added to the fallback, the fallback atlas texture will be uninitialized at a size of zero thus no real memory footprint.

    Note that font assets can also be created at runtime and potentially assigned as fallback as well.

    In the next release of TMP, the Multi Atlas Texture feature will be available where additional font assets are created on demand. So in your example above, once the 2048 x 2048 texture is full, a 2nd atlas texture of the same size will be created to accommodate the additional glyphs and characters.

    This Multi Atlas Texture feature works on all font assets. So your primary could remain static and contain all the known characters in the project for a given language or groups of language. Then a dynamic fallback with Multi Atlas Texture enabled could be assigned to the primary to catch all other glyphs and characters.
     
  22. OneManEscapePlan

    OneManEscapePlan

    Joined:
    Oct 14, 2015
    Posts:
    218
    Okay, thanks for the information!

    It's a bit off-topic, but it would be very great if you could convince the other staff at Unity to make TMP text components share a common base class or interface with Unity's built-in text components. It is an annoying hassle having to go through each component script and change UnityEngine.UI.Text to TMP_Text when converting an existing project to TMP.

    At the very least, all of the text classes could share some interface like this:

    Code (CSharp):
    1. public interface IText {
    2.     string Text { get; set }
    3. }
    Even though interface fields can't be assigned in the Inspector, it would make life easier when converting a project to TMP or building a project that mixes TMP and legacy text.
     
  23. classicalguss

    classicalguss

    Joined:
    Apr 15, 2018
    Posts:
    6
    We still haven't upgraded to TMP version 1.4 but our company is planning to do so. One thing I'd like to know, what is the best way to seamlessly handle emoji country flags such as US Flag Emoji, at the moment in version 1.3 we're having trouble handling it. Since these flags seem to contain 2 UTF32 characters, TextMesh pro will just render them as Letter symbols such as U and S. Can version 1.4 handle this issue better? And if possible, can you help us in finding a solution to do it in version 1.3?

    Appreciate your reply Stephan
     
  24. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    No improvements in regards to handling of Emoji combinations / modifiers in version 1.4.0. Support for Ligatures which are essential Emoji combinations / modifiers is in the works.
     
  25. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    TryAddCharacters still seems to always throw NullReferenceException in the latest preview. [Edit] Ah, it seems to work if you only create the font asset in run-time.

    Also, is TryAddCharacters only to be used on dynamic font assets or would it be possible use this to add characters to static font assets via editor scripting?
     
    Last edited: Apr 30, 2019
  26. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The expected use for this function was certainly runtime but how were you using it that was resulting in null reference exceptions?

    It is (only to be used with Dynamic font assets) and in version 1.4.1-preview.1, this function should throw a warning when the font asset is static.
     
    Last edited: Apr 30, 2019
  27. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    I created a dynamic font asset in editor and then tried to add characters to it on runtime with TryAddCharacters. That threw the exception.

    Trying to find a way to make an editor script to generate the font assets automatically. Version 1.3.0 seemed to have
    TMPro_FontPlugin.Render_Characters but is that not available anymore in 1.4.0?
     
  28. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you provide a simple script or repro scene that will enable me to reproduce this issue?

    The new Dynamic system relies on the new FontEngine which is runtime and on all platforms. The old plugin was Editor only and only for Windows and Mac.
     
  29. ManuelRauber

    ManuelRauber

    Joined:
    Apr 3, 2015
    Posts:
    122
    Hi @Stephan_B

    I still get the same error:

    Code (CSharp):
    1. Library/PackageCache/com.unity.textmeshpro@2.0.1-preview.1/Scripts/Editor/TMP_SettingsEditor.cs(332,91): error CS0407: 'Object TMP_ResourceImporterProvider.GetTMPSettings()' has the wrong return type
    2.  
    I'm using:

    * Unity 2019.1.0f2
    * TextMesh Pro 2.0.1-preview.1

    upload_2019-5-1_16-7-12.png

    I've re-imported the essentials (or deleted them in another test), and I reimported everything within Unity (t.b.h. I used
    git clean -xdf
    to remove anything related to caches etc.).

    However, I've found the following behavior: When re-importing everything, it works. If I switch to iOS platform then the error occurs and stays even when switching back to Desktop platform.
     
  30. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    See the following thread as it may contain the solution for this issue. Please post any update in that other thread which is specific to the .Net change.
     
  31. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    Apparently, works fine on new projects. I'll try to investigate.

    There is no way to generate font assets via editor script in 1.4 yet? That would be really useful to keep font assets up date with the localization files.
     
  32. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You should be able to do so but the font asset has to be marked as Dynamic. Once generated, you should be able to switch it to static.

    Let me know if you run into any issues there.
     
  33. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    In an existing project that was upgraded from 1.3, when a new dynamic font asset is created Sampling Point Size defaults to zero, along with all the other settings under Face Info. Also, every time Sampling Point Size is changed and Apply is pressed it is set to zero instead. New projects do not have this problem. I have tried removing TMP Settings. Is there anything else I could try to reset to get around this problem?

    [Edit] To answer my own question: Incl. Font Data needs to be enabled in Font settings
     
    Last edited: May 6, 2019
  34. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Correct as otherwise, the font data (raw font file) is not included with the Unity font.

    I'll take a look if I can add a warning on this. Normally, Incl. Font Data is enabled by default on Fonts set to Dynamic (legacy Unity dynamic mode).
     
  35. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    There seems to be some performance impact in attempting to add a character to a dynamic font asset that doesn't actually exist in the source font. This could become an issue when we have lots of user text input by the users, as some user may figure out the delay problem and spam the chat with non-existing characters. We'll implement client-side stripping of these characters for now. I have attached a sample project to demonstrate the issue. There pressing a button to display a mockup chat takes several seconds to process. The delay seems to be multiplied by the use of layout groups.

    A couple of other small things:
    - The sample project includes another scene to demonstrate the issue I had earlier. I figured you need clear the font asset before you can call TryAddCharacters.
    - Trying to create dynamic font asset in a new project before TMP Importer is run throws an exception.

    Note: I had to remove TextMeshPro from the zip to get around the file size limit.
     

    Attached Files:

  36. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Thanks for the sample project.

    I already looked at it briefly and was able to reproduce the reported behavior. I'll take a closer look tomorrow to figure out what is going on.
     
    dai50 likes this.
  37. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    Thank you!

    Also getting these exceptions when attempting to use emojis from two different texture atlases. Not sure how much it is related to that but I have attached another sample project that should be able reproduce it. As I had to remove TextMeshPro from the archive again, you also need to setup the Default Sprite Asset to "emoji-base-sheet" in the TextMeshPro settings. Then pressing the button should trigger these exceptions.

     

    Attached Files:

  38. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    Reported some other issues I run into via the bug reporter: case id 1152711
     
  39. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What is the alignment issue?

    P.S. Currently working on the performance issue with missing glyphs.

    I'll take a look at the other issues once I am done with this first one.

    Keep those reports / repro scenes coming. Just try to add a little bit more details on each scenes / expected results vs. the issue.

    Also where possible, include the pre upgrade versions of the projects. This allows me to also test the upgrade process using a clean / never converted version of the resources / assets.
     
    Last edited: May 8, 2019
  40. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    Attached a screenshot. Happened to some text components. You can kind of fix it by changing the alignment to center and then back to left. There should be a sample scene included for that case also.
     

    Attached Files:

    Stephan_B likes this.
  41. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    In regards to the performance issue when trying to add lots of missing characters, here are the Profiler results before and after.

    upload_2019-5-8_3-30-46.png

    After some changes in the FontEngine.

    upload_2019-5-8_3-30-53.png

    The example scene / case you presented was pretty much a worst case scenario in terms of loading of font files.

    I still need to do some additional changes and testing of course. These changes are in the FontEngine which is part of Unity and not the TMP Package itself. As such I need to have a discussion with the Release Management folks to see if I can get these changes into 2018.3.

    I'll finish working on this tomorrow and take a look at your other reports.
     
    Last edited: May 8, 2019
    dai50 likes this.
  42. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    I also have the issue of Unity becoming unresponsive with 1.4.0.

    It does a couple of font upgrades quickly, then as soon as I open our mainmenu, Unity becomes unresponsive and stays that way.

    The console becomes frozen as well, but in the editor log I can see the following:

    Code (csharp):
    1. Updating Assets/Fonts/latin_new.asset - GUID: a65babff9c620124c9166c07dbc83377...
    2.  done. [Time: 78.510022 ms]
    And then this 5 times (I left only the relevant parts)/
    Code (csharp):
    1. Assertion failed on expression: 'HasValidGameObject(liveObject)'
    2. UnityEditor.AssetDatabase:SaveAssets()
    3. TMPro.TMP_FontAsset:UpgradeFontAsset() (at Library/PackageCache/com.unity.textmeshpro@1.4.0/Scripts/Runtime/TMP_FontAsset.cs:1853)
    4. TMPro.TMP_FontAsset:Awake() (at Library/PackageCache/com.unity.textmeshpro@1.4.0/Scripts/Runtime/TMP_FontAsset.cs:482)
    5. (...)
    6. [/Users/builduser/buildslave/unity/build/Runtime/Misc/GarbageCollectSharedAssets.cpp line 815]
    7. (Filename: Library/PackageCache/com.unity.textmeshpro@1.4.0/Scripts/Runtime/TMP_FontAsset.cs Line: 1853)
    Should note: I'm on latest 2018.3 and on a Mac.
     
  43. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    Also how can I make it stop spamming me?

    I don't want Underline and Strikethrough, or ellipsis, and I don't use them, this font only has numbers, why is it spamming me?
     
  44. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Upgrade to version 1.4.1-preview.1 which was release specifically to address that issue.

    In terms of the Underline, Strikethrough and Ellipsis, disable the warnings in the TMP Settings.
     
    AcidArrow likes this.
  45. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    Cool, 1.4.1 did not make the editor freeze, but now I have another (less major) issue.

    The generation settings seem to be different than the actual settings.

    see:

    Screenshot 2019-05-09 at 10.24.57.png

    So weirdly, they have things like different render modes, which is kinda weird and not a deal breaker.

    The problematic part is that the "Generation Settings" are always missing the Source Font File, which made me mistakenly obliterate a bunch of fonts (making a change and hit apply messes up the font, the atlas is still there, the character sequence is gone though and the font disappears from the scene)
     
  46. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    For static font assets, a reference to the source font file is not required.

    For dynamic font assets, a reference is required and should be setup / manually referenced via the inspector.

    In version 2.0.0, TMP was attempting to auto reference the source font file using the GUID stored in the old generation settings but that is what was causing the Freeze in the Editor. Upgrading single font assets worked fine but when a user would open a scene that referenced several font assets with fallbacks, the freeze would occur.

    The freeze is related to the use of AssetDatabase functions and Resource.Load while the font assets were getting converted. Ie. this is a Unity bug (not specific to TMP) but as usual exposed by TMP because I seem to have the magical touch in exposing random / strange issues.

    In terms of the Render Modes, they should match. Can you provide me with one of those font assets (pre upgrade to the latest version of TMP) so I can take a look at it?
     
  47. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    Okay, but maybe if the source font asset is missing, maybe don't allow me to change any settings? I went to change the padding, hit apply, the altas didn't change but all other data was gone.

    I'm pming you a link to a font asset. All the fonts in my project seem to exhibit this behaviour, but I tested a few on a new project and they do it there too.
     
  48. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    When you have TMP_InputField with Content Type set to Custom, the mobile keyboard won't show up on Android nor iOS.
     
  49. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    That is (sort of) by design as users who implement their own keyboards / layout use that option.

    Can you provide more insight on how you are using this Content Type Custom option?

    P.S. Since input field stuff is not specific to the Dynamic SDF system, please post in the Unity UI & TextMesh Pro forum section as it makes it easier to track those individual topics and easier to find for users who search.
     
    Last edited: May 10, 2019
  50. dai50

    dai50

    Joined:
    Dec 27, 2018
    Posts:
    14
    I see! In 1.3 it used to bring up the mobile keyboard, and that's why I noticed it. I don't think we had any real reason to use custom, since the predefined options seem to do the same.