Feedback wanted : new text engine

Regarding the rich text possibilities. I’m using Unity 2021.2.5f and I would like to add hyperlinks to my application. The tag is getting recognized in UI builder but it doesn’t open Google.com for example. So I found that for TMP I have to get the link ID and then write my own Application.OpenURL() logic. I was thinking about using RegisterCallback() but this way is only working for the whole Label element. My question is, how do I make sure the click event is fired and that I can use its ID in code?

1 Like

Hi @Thimo , it is on our roadmap, but it’s unfortunately not yet supported.

As you mentioned, in the meantime, the workaround is to insert the hyperlink in its own label and add a RegisterCallback to it.

We plan to add a tag that calls Application.OpenURL() with the specified URL in the near future. Would this suit your needs?

We are also planning to add the logic to allow users to hook custom callbacks to tags. However, this will come later.

2 Likes

Hey! Just wondering if you were able to squeeze this into 2022.1?

Its vital for my font as it is weird with its centering and only those additional alignment options get a perfect center. Also the line height is also a need for my font.

Have a great holiday :slight_smile:

1 Like

Hi @MousePods !

Unfortunately, we didn’t manage to add this in 2022.1, but have you tried to change the different metrics in the FontAsset Inspector of the FontAsset you are using? You should be able to tweak the LineHeight to achieve the desired results.

Thanks, and happy holidays to you as well!

2 Likes

The tag would be perfect to add to UI toolkit in my opinion!
Do you have a prediction for when this feature will be addded 2022.1? or 2022.2?

Thanks in advance!

Thanks for the tip! It looks like this will be a last resort if the features aren’t out yet before the end of 2022. Do you know by any chance if it will make it into 2022.2?

Thanks!

I have a problem with the <align=justified> tag. If the length in pixels of the line is only a little bigger than available space then instead of wrapping it will go outside the box. The problem is both at runtime and UI Builder.

1 Like

Hi @vejab ,

Thanks for highlighting this issue! That seems to be a bug on our end, could you please report this through the unity bug reporter and post the issue number so we can track it?

Thanks : 1397616

1 Like

Trying to use a FontAsset in 2021.2.9f1 and while it works, all input fields will not accept input. I can press backspace and enter and they are both registered. If I switch back to the default and it works fine.

When I add the font asset in UIBuilder the console starts to spit out error messages.

Cannot process a null font.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

And

AssertionException: Assertion failure. Value was Null
Expected: Value was not Null
UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) (at <898af1af8ccf490a906c218e1e74b230>:0)
UnityEngine.Assertions.Assert.IsNotNull (UnityEngine.Object value, System.String message) (at <898af1af8ccf490a906c218e1e74b230>:0)
UnityEngine.Assertions.Assert.IsNotNull[T] (T value, System.String message) (at <898af1af8ccf490a906c218e1e74b230>:0)
UnityEngine.Assertions.Assert.IsNotNull[T] (T value) (at <898af1af8ccf490a906c218e1e74b230>:0)
UnityEngine.UIElements.TextNativeHandle.GetVertices (UnityEngine.UIElements.MeshGenerationContextUtils+TextParams parms, System.Single scaling) (at <40001ab788e241b094dbea03f2ab96e8>:0)
UnityEngine.UIElements.UIR.Implementation.UIRStylePainter.DrawTextNative (UnityEngine.UIElements.MeshGenerationContextUtils+TextParams textParams, UnityEngine.UIElements.ITextHandle handle, System.Single pixelsPerPoint) (at <40001ab788e241b094dbea03f2ab96e8>:0)
UnityEngine.UIElements.UIR.Implementation.UIRStylePainter.DrawText (UnityEngine.UIElements.MeshGenerationContextUtils+TextParams textParams, UnityEngine.UIElements.ITextHandle handle, System.Single pixelsPerPoint) (at <40001ab788e241b094dbea03f2ab96e8>:0)
UnityEngine.UIElements.MeshGenerationContextUtils.Text (UnityEngine.UIElements.MeshGenerationContext mgc, UnityEngine.UIElements.MeshGenerationContextUtils+TextParams textParams, UnityEngine.UIElements.ITextHandle handle, System.Single pixelsPerPoint) (at <40001ab788e241b094dbea03f2ab96e8>:0)
UnityEngine.UIElements.TextInputBaseField`1+TextInputBase[TValueType].OnGenerateVisualContent (UnityEngine.UIElements.MeshGenerationContext mgc) (at <40001ab788e241b094dbea03f2ab96e8>:0)
UnityEngine.UIElements.VisualElement.InvokeGenerateVisualContent (UnityEngine.UIElements.MeshGenerationContext mgc) (at <40001ab788e241b094dbea03f2ab96e8>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Not sure what’s happening. The text is rendered with the proper font, input doesn’t work and I get these messages spamming the console while UIBuilder is open and I do anything in it.

I even tried the default font as a font asset and it is the same, no font asset will allow me to use the TextField for input accept the default one built in. This is on a fresh project, no packages installed other than the ones the 2D template installs. Tried in a build as well, still didn’t work.

Edit:
Filed a bug report: Case 1399149

1 Like

Please make it so that I can add system fonts as fallback. This is very much needed for localization and emoji, especially in mobile without bloating the build with huge fonts.

I found this Load font from mobile device and assign as fallback TMP_FontAsset
and it helped a lot,
But that does not work at editor time.

It would be great if in the font asset I could just specify a list of system fonts to use as fallback, for example:

Roboto
Helvetica
Arial

And it would use them if it finds them. It would also really help if this worked at editor time. Heck, I would create an empty font asset and rely only on system fonts if I could.

2 Likes

Hi @goldbug ,

I’m glad you brought up the question as I think it’s the first time we discuss “Dynamic OS Font” on the UI Toolkit forum. The good news is TextCore already supports Dynamic OS Font Assets. It’s a dynamic font asset but the source font file isn’t exported to the player build. Instead, it will use the font on the target platform that matches the family name and the style name.

To create a Dynamic OS FontAsset, you first need to import the desired font to your project in the Editor and create a FontAsset from that font. You can then switch its Atlas PopulationMode to “Dynamic OS” under the Generation Settings tab.

We are aware we are lacking documentation on this, but I hope this helps in the meantime!

5 Likes

@HugoBD-Unity I was trying to get the sprite tag to work for textcore in UI Builder without including text mesh pro. But I couldn’t get it to work. For the example below only worked with text mesh pro added.

<sprite=0>

Also sprite tags with name and indexed didn’t seem to work even when text mesh pro was added.

<sprite=“name” index=1>

Do you know if textcore supports behaviour or if we still need text mesh pro for this specific use case.

@BlackSpider Unfortunately, the tag is currently not supported in the Editor. It should work in the GameView and at runtime though.

It’s something we are looking to add support for at some point, but I can’t give a precise estimate.

1 Like

@HugoBD-Unity Thanks for the quick reply. So you say it should work without textmeshpro in the gameview?

I will dig a bit deeper into debugging this tomorrow as I think the classes are inside the textcore package that handle the sprite tag behaviour.

UPDATE: Noticed it didn’t load properly due to me forgetting a / at the end of the resources path in the UITK Text Settings for Sprite Assets.

And it also showed up correctly in my UI Builder which surprised me.

1 Like

Do we have any update on this?

Please have a tick box for a fallback to system font like every other modern softwares out there when the font/character isn’t available. So there will be an option to beta test with non-english audience until we are actually ready to invest in localization fonts.

2 Likes

New text system sounds great

The most annoying thing in textmesh pro aside of the material errors is:

Rich text codes are extremely inefficient

writing <style= > or even is way too much if you gotta do it hundreds of times
Like in markdown, bold should be just 1 key text

compare the loops you have to go through:

*
text
*

to:

<
b
>
text
<
/
b
>

Not to forget that writing > and / requires both hands and if you write a lot of text this becomes like finger acrobatics for every paragraph.

Please change this, its absolutely painful
A modder for our game wrote a custom auto completion windows tool because this is so inefficient. Also the readability for the text and for localizers is really bad.
Honestly I am afraid that some localizers will just not want to do it when seeing this.

Increases <style=crit>criticalchance by 20%

Increases ‘‘s=crit’‘critical’’ chance by ‘20%’

something smarter along these lines could be a 2-500% workflow improvement

Why don’t you create an extension function that converts aaa to aaa?

2 Likes

Well for rich text codes you can not use an escaped character like " and other characters are valid in a string!
What it could use is a WYSIWYG editor with buttons to toggle bold/italic etc. - rather like you are using in this forum!
If you are typing out text in code then use your own syntax and convert with an extension method on applying to a text field