Search Unity

Official Feedback wanted : new text engine

Discussion in 'UI Toolkit' started by antoine-unity, Nov 17, 2020.

  1. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Hello, today we are excited to share with you the last major addition to UI Toolkit 1.0, namely the integration of a text engine coming directly from Text Mesh Pro. The name of this engine is TextCore and is being directly integrated into Unity, with the long term goal of supporting the entire ecosystem (including migration of existing Text Mesh Pro users).



    About the new engine

    The TextCore engine has a set of characteristics that makes it much more appealing for UI Toolkit developers:
    • Clear separation of text layout, mesh generation, and rendering operations of text objects
    • Signed Distance Field capabilities, which bring performance improvements and less memory overhead for multiple text sizes
    • Ability to embed static font data and limit dependencies on FreeType in the future

    Since the engine is a direct adaptation of Text Mesh Pro, so it allows us to actually support many equivalent features and continue our journey towards parity with UGUI & TMP.

    Getting started

    Please have a look at this getting started guide to learn more about what this new release gives you access to.

    Known issues

    Currently the only known bug for this feature is the following:
    As much as possible we will keep this list updated for your information :)

    Next Steps

    You can expect a UI Builder update very soon in order to work with the new Font Asset support and other text options.

    In future releases, we have some plans for the following improvements:
    • Support rich text strings for TextFields
    • Improve the readability of Rich Text Tags in raw UXML
    • Support for whitespace CSS properties
    • Support for paginated text elements
    • Support for <link> tags

    We’re eager to hear your feedback on these new features ! Please let us know if this is matching your needs and what you’d like to see prioritized.

    Thanks.
     
    Last edited: Nov 17, 2020
  2. Refeas

    Refeas

    Joined:
    Nov 8, 2016
    Posts:
    192
    Hi,
    thanks for adding this feature set! I've been really looking forward to it, keep up the good work. :) I would like to know if
    text-shadow
    is supposed to work on Buttons? Because it seems it only works on Labels (I've only seen TextField being mentioned as not working yet).

    Thanks!
     
  3. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Thanks for the new features!

    I noticed that paragraph spacing, word spacing, and character spacing are supported, however, I don't see line spacing. Is this something that is coming soon?
     
    Last edited: Nov 18, 2020
    FizzFab likes this.
  4. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    Can you make this one the default and if you want to keep the other text options available to users for backward compatibility make those older versions into packages they can install? I don't like that obsolete features are default and new features are packages you have to hunt for, install and manage versions yourself.... it makes no sense.
     
  5. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    When using large values for the rotate tag it doesn't really render correctly, the next character overlaps with this one(try using 90 or 180)
     
  6. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    It'd be really great if we can use html tags as well. so setting an html article text render it as good as possible
     
  7. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    I would like it when the ui builder supports the "Text Panel Settings".
    I have a font asset with a fallback font with special characters, and at the moment those are not shown in the uibuilder. because it doesn't know the fallback font.
     
  8. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Can you clarify what you are referring to here?

    Hello, this one will come a little later. However in the meantime you can use
     <line-height=5>
    or
    <line-height=150%>
    in the Rich Text Tags.
     
  9. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    We'll investigate, thanks for reporting.
     
    Last edited: Nov 18, 2020
  10. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    Hi,

    >I would like it when the ui builder supports the "Text Panel Settings".
    I have a font asset with a fallback font with special characters, and at the moment those are not shown in the uibuilder. because it doesn't know the fallback font.

    The next version of the UI Builder will enable users to specify a FontAsset as well as set new Text properties (Text Shadow, Text Outline) & support rich text for all text elements (except TextField). Text Settings is specified via Panel Settings, which will come at a later time.
     
    manuelgoellnitz likes this.
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The <rotate> tag only affects the geometry of the characters and not the metrics. As such, the Advance (spacing between characters) is not adjusted which can result in characters overlapping as most of the time their height is greater than their width.

    Having said that, what is your use case for the <rotate> tag?

    BTW: Most of the projects I have seen using the <rotate> tag in TMP were to sort of style and in some case animate the characters using small rotation angles.

    P.S. Please consider making a separate thread for this as it will make it easier for us to continue our conversation about the <rotate> tag and for other users to find it as well over time.
     
  12. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    The general state of how unity is being developed at the moment is to put all new features into packages that need to be installed separately and also updated separately to the main unity build. I understand why this is the case but I think you need to reverse it. Make unity automatically start with the latest and greatest systems, eg text mesh pro over text mesh and allow users to install older systems through the package manager if they require it for backward compatibility rather than the other way around, especially if that older system is considered obsolete.
     
    MegamaDev and IOU_RAY like this.
  13. norgalyn

    norgalyn

    Joined:
    Feb 15, 2014
    Posts:
    8
    This is really nice, one feature I am missing that was not mentioned is sprites respecting text order e.g. if sprite has AD < width the following text overlaps the sprite.
     
  14. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    A common use case is the sprite with Zero Advance being used to define some shape (a coin for instance) where a subsequent character (a number) with adjustment pair defined between the two is displayed on top of the sprite.

    What is the use case for subsequent character to be under the sprite?
     
  15. norgalyn

    norgalyn

    Joined:
    Feb 15, 2014
    Posts:
    8
    I could have been more clear, sorry. Your use case is exactly what I had in mind. I am setting AD=0 and the text is behind the sprite. E.g.
    <sprite=0>10
    leads to only the sprite being visible.
     
  16. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Thanks for clarifying.

    Let me see if I can figure out a way to make this work.

    Can you think of a use case where we would not want the subsequent character to be on top of the preceding sprite? Ie. Maybe sprites should always be rendered first.
     
  17. norgalyn

    norgalyn

    Joined:
    Feb 15, 2014
    Posts:
    8
    I personally can't really, but you might want to be careful as I guess that <mark> works by drawing a tinted sprite over the text, so this change could turn it into a <background> tag instead. Which could be useful as mark changes the text's color and has to have alpha making background visible.
     
    HugoBD-Unity likes this.
  18. R4vakk

    R4vakk

    Joined:
    Oct 10, 2015
    Posts:
    17
    I'm also really interested in a solution for this.

    Also, is there any plan to add a feature akin to the TMP Text Info Debug Tool ?
     
  19. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    How do I set the text-shadow to be a solid color and not <1 alpha? I am trying to use it for the dilate feature and not a shadow.
     
  20. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    I can confirm that text-shadow doesn't apply to Buttons or Labels that have the Background property set to a color.

    I have a few Labels that have backgrounds that don't get the shadow. I am using a label for the element in a ListView that sets the background when the item is selected. The shadow disappears when selected and when the item isn't selected it has the shadow again.
     
  21. justDax

    justDax

    Joined:
    Mar 29, 2020
    Posts:
    3
    Lot of amazing features, great job!

    In CSS you can add multiple comma separated text-shadows, something like:
    Code (CSharp):
    1.   text-shadow: -1px -1px 0 #000,  0 -1px 0 #000;
    Will this feature be supported?
    This will help to achieve a text outline effect outside the font itself, the actual implementation of the outline which I believe behaves like the css equivalent is currenly "eating inside the font" making it not much usable on small font sizes
     
  22. HugoBD-Unity

    HugoBD-Unity

    Unity Technologies

    Joined:
    May 14, 2018
    Posts:
    499
    Yes, it's definitely something we plan on adding, but unfortunately, I don't see it happening in a recent release.
     
  23. HugoBD-Unity

    HugoBD-Unity

    Unity Technologies

    Joined:
    May 14, 2018
    Posts:
    499
    @Chris-Trueman Thanks for bringing it up. We have a fix for text-shadow coming up in the next package release.
     
  24. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    This is now fixed in preview 13
     
  25. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    @Stephan_B is there a way to set the alpha of the text shadow?

    Setting the color doesn't seem to affect the alpha, not sure what the procedure is for this.
     
  26. Crayz

    Crayz

    Joined:
    Mar 17, 2014
    Posts:
    194
    I'm trying to apply -text-shadow but getting this in editor, untested in build:

    03YtjU1.png (491×123) (imgur.com)

    Here's my css:

    Code (csharp):
    1. .panel .header Label {
    2.     -unity-font-definition: url("/Assets/UI Toolkit/Resources/Fonts & Materials/LiberationSans SDF.asset");
    3.     color:white;
    4.     -unity-font-style:bold;
    5.     text-shadow: 2px 2px 5px black;
    6. }
    Not sure if bug or I'm missing something?

    Unity 2020.2.0b14 (also occurs in 2020.2.0b9)
    UI Toolkit 1.0.0-preview.13
     
    Last edited: Dec 5, 2020
  27. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    It does this in uGUI as well, it only has a quad to work with and its only so big. It works better with larger font sizes, the smaller the font the smaller the area to work with so you need to adjust accordingly and 5 pixels is quite large for that font size.
     
    Crayz likes this.
  28. JohnAustinPontoco

    JohnAustinPontoco

    Joined:
    Dec 23, 2013
    Posts:
    283
    Are you planning on keeping the Sprite Asset from TextMeshPro? I really hope you aren't, because they're really rough.

    I've spent half a day just today trying to get a handful of new icons aligning properly with text. The only way to do it is to modify the Glyph parameters of every single one of our 100's of icons by hand. It's terrible. And on top of that it doesn't even work with the built-in sprite packer.

    Full respect to the folks that work on TextMeshPro. I'm sure the engine underneath is great, but the workflows.. not so much. It'd be great to see these re-built with the new Asset Database and the same level of polish that has gone into the rest of the UI Toolkit.
     
    Last edited: Dec 10, 2020
  29. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    I am having a hard time getting TMP text highlighting to render behind the text rather than above the text.
    Using an image UI as the parent object is not helpful, because it does not play well with layouts. (Need to use the text scaling)

    I hope this can be sorted out.
     
  30. Nexer8

    Nexer8

    Joined:
    Dec 10, 2017
    Posts:
    271
    Working with the C# part of Text Core. What are the steps necessary to go from a FontAsset assigned in the inspector to a StyleFontDefinition I can apply to a VisualElement style?
     
  31. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    I am using Unity 2020.1.17 and have updated UI Toolkit runtime and builder packages to their latest version.

    When inspecting the text properties inside UI Builder, there is the following helpbox :
    upload_2020-12-22_19-2-24.png
    Rich text properties can be made accessible by installing the latest UI Toolkit package

    I see that this helpbox appears if PACKAGE_TEXT_CORE is not defined.
    PACKAGE_TEXT_CORE seems to be defined only if the project has the "com.unity.textcore" package, but I am not sure at all that this is available in Unity 2020.1.

    Is the new text engine (and UIToolkit Rich Text features) unavailable in Unity 2020.1 ? What about 2020.2 ?
     
    marcospgp and Nexer8 like this.
  32. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Right now UIBuilder setting up Rich Text/FontAssets are out of commission. You can still setup FontAssets but not in the builder. It is only compatible with 2021.1 and UITK preview 13 but preview 13 isn't compatible with 2021.1 so we have to wait until preview 14 comes out and hopefully it will all work..
     
  33. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Found some other little annoying bugs.

    Having an outline and/or shadow and fading the text does nothing to the outline and/or shadow, it shows with 0 opacity.

    I am using the shadow like a glow, so its offset is 0px 0px, however if I modify the uxml in UIBuilder it overwrites those values and puts 0 0 which doesn't work, no shadow is displayed. I have to manually edit my uss to add the px so it will work.

    The font asset creator information panel is a fixed size and cannot be made to fit. This is a problem as half of it is cut off for me so I need to scroll to the right to see that part of the info panel. I thought I was able to adjust the atlas view but I cannot. Resizing the window moves the atlas view to the bottom and shows the full info panel, but its now bigger than my screen is tall. Its not a huge deal, only takes a few seconds to make the font asset, but it just makes it take a little longer than before.
     
  34. RichardGoesToNightSchool

    RichardGoesToNightSchool

    Joined:
    Dec 9, 2020
    Posts:
    27
    Is there a way to make a bulleted list using or uss?
    Something like css lists
    Can I create my own custom tags somehow?
     
  35. dujimache123

    dujimache123

    Joined:
    Sep 8, 2020
    Posts:
    10

    Will UIToolKit 1.1 support "
    • Support rich text strings for TextFields
    "????
     
  36. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    194
    It's about time you guys get that Getting Started guide out of a Google Doc and into the official documentation!
     
    tonytopper and benoitd_unity like this.
  37. Lhawika

    Lhawika

    Joined:
    May 27, 2015
    Posts:
    53
    Hi,

    I am working on a project where we need to load fonts dynamically, from addressables.
    With TextMeshPro, it has been a real pain to implement properly and have it to work as intended since TextMeshPro has no support for addressables.

    Do you plan to make this easier with this package ?

    The reason we need addressables is to avoid keeping fonts textures that are useless for the currently displayed language (think of Japanese and Chinese fonts being loaded when playing the game in english) to avoid wasting memory.

    Edit: Actually, more generally speaking, it would be great to have a way to avoid using "Resources" folders altogether.
     
  38. Morphus74

    Morphus74

    Joined:
    Jun 12, 2018
    Posts:
    174
    Hi,

    Does the new text field/text input now support Arabic (Right to Left) language properly, with correct ligature?

    The current version of TextMeshPro, doesn't support RTL language properly, for proper ligature you need to use a RTL extension.

    So is the current Text module suffering from the same defiency? Or did I miss a TMP update?

    Thank
     
  39. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    might be late to the game but, I'm wondering how easily this will handle frame-animated sprites
     
  40. Kirsche

    Kirsche

    Joined:
    Apr 14, 2015
    Posts:
    121
    Kandy_Man likes this.
  41. broots

    broots

    Joined:
    Dec 20, 2019
    Posts:
    54
    Having poked around with this system there's a big feature gap between this package and text mesh pro. As Kirsche said above, the first thing I looked for was a way to render max visible characters like TMPro but there's no easy way. Additionally, not being able to get ahold of vertex/mesh data seems like a big regression from TMPro. Having this encapsulated away means that you cannot procedurally animate text which is something trivial to do in TMPro.

    It seems like a step backwards for unity to move to a less powerful text rendering engine when text is such a powerful tool in game design. Would it be possible to have a UITK Text Settings asset that allowed for the direct usage of TMPro for users who wanted the flexibility? The only alternative for users with this requirement would then be mixing old and new GUI systems which seems undesireable, or simply not being able to do achieve the effect they're looking for because the glyphs are out-of-reach.
     
    april_4_short and marcospgp like this.
  42. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    194
    I am on the latest version of both UI Toolkit and UI Builder and I am still seeing this:

    upload_2021-1-25_11-42-22.png

    What is going on here? Why would UI Builder ask for a newer version if I have the latest version installed? I can't see any reason why this would happen even if there's miscommunication between the two teams, and am utterly confused o_O
     
    Midiphony-panda likes this.
  43. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    Last edited: Jan 25, 2021
    marcospgp likes this.
  44. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Its because to use UIBuilder with the new text features you need 2021.1, but the UITK package is incompatible with it right now. You're stuck manually editing the uss files to add the features. Hope they correct that soon its been almost 2 months (last update was Dec 1, 2020.)

    You can use them in 2020.2, just not with UIBuilder.
     
    Midiphony-panda and marcospgp like this.
  45. herra_lehtiniemi

    herra_lehtiniemi

    Joined:
    Feb 12, 2017
    Posts:
    133
    I know you guys probably get this a lot, but I was wondering what is the currently estimated timeframe for Rich text support in UI Toolkit TextFields (preview version)?
     
  46. skowroshima

    skowroshima

    Joined:
    Oct 14, 2018
    Posts:
    75
    It still appears to me like this isn't working for button text (Using Preview.14). Any different syntax?

    .eButton {
    -unity-font-definition: url("/Assets/UI Toolkit/Resources/Fonts & Materials/LiberationSans SDF.asset");
    text-shadow: 1px 1px 2px red;
    }
     
  47. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Rich text in UI Builder is only available when 2021.1 is installed.
    https://forum.unity.com/threads/ui-builder-rich-text-properties.1020331/
     
    Midiphony-panda likes this.
  48. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    When you have the package installed, it should work with 2020.2 as well, however UI Builder won't show the properties (see above). As such, it might difficult to use it in this version if you're not keen on using UXML/USS directly.
     
  49. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Currently this feature is planned for Unity 2022 so it won't be available in preview/alpha before end of 2021 and it could slip the first half of 2022.
     
  50. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Sorry for the late response. That looks like this should work (the syntax is right). Please report a bug so we can investigate.