Author Topic: "Typewriter effect" leading to weird corrupted characters  (Read 85 times)

johnnemann

  • Newbie
  • *
  • Posts: 17
"Typewriter effect" leading to weird corrupted characters
« on: November 28, 2018, 04:37:22 PM »
Hi,

This is a new problem we're seeing, where some of our text that is being displayed through the maxVisibleCharacters "Typewriter effect" changes and becomes corrupted. The problem seems to occur after opening another panel with a few TMP objects on it.

Here's what we're seeing, attached (in the box at the bottom).

Any help appreciated!

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5640
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #1 on: November 29, 2018, 01:14:16 AM »
Looks like the UV coordinates for those characters is wrong or somehow the atlas texture used by that font asset is incorrect.

johnnemann

  • Newbie
  • *
  • Posts: 17
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #2 on: November 29, 2018, 09:03:42 AM »
It displays correctly at first, but eventually corrupts like that.... it's the same font as the other text on the screen.

How would I fix this?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5640
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #3 on: November 30, 2018, 01:14:56 PM »
It displays correctly at first, but eventually corrupts like that.... it's the same font as the other text on the screen.

How would I fix this?

So all the visible text is using the same font asset but only the bottom one gets corrupted?

If you disable the typewriter FX does the issue still eventually occur?

Do you have any script that is accessing / modifying vertex attributes of that text object?

Are any fallbacks used in that text object?


johnnemann

  • Newbie
  • *
  • Posts: 17
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #4 on: November 30, 2018, 01:18:24 PM »
Yes, that's right.
As far as I can tell everything in the game is using the same font asset.
Only that text gets corrupted.
I'm not modifying any vertex attributes or doing anything fancy (there is a word wrap set up on that box, though, unlike the other text).
No fallbacks are used.

I will test without the typewriter effect (and word wrap, too) and post the results.

johnnemann

  • Newbie
  • *
  • Posts: 17
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #5 on: December 01, 2018, 11:09:40 AM »
Turning off the typewriter effect does not make a difference - not sure what's going on.

It's caused seemingly by enabling another panel in the game. That panel has 4-5 TMP boxes, all with the same font, and a few images.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5640
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #6 on: December 01, 2018, 11:47:30 AM »
Turning off the typewriter effect does not make a difference - not sure what's going on.

It's caused seemingly by enabling another panel in the game. That panel has 4-5 TMP boxes, all with the same font, and a few images.

This also happens on desktop / in the editor correct?

If you are in the editor, when this behavior occurs, can you check what material / atlas texture (both) this object points to?

When you select the text object with the corrupted text, is it using sub mesh objects?

johnnemann

  • Newbie
  • *
  • Posts: 17
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #7 on: December 01, 2018, 12:13:12 PM »
OK, weird. Yeah, the material it's using is for a different font (I've attached an image of the inspector while this is happening - it's set to use "Montserrat SDF" but the material is actually "LiberationSans SDF".

The LiberationSans is a font that is in the project, and is a font we've used in the past and may be using elsewhere currently, but I am not sure why it's becoming the font material for this text box...

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5640
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #8 on: December 01, 2018, 02:01:21 PM »
OK, weird. Yeah, the material it's using is for a different font (I've attached an image of the inspector while this is happening - it's set to use "Montserrat SDF" but the material is actually "LiberationSans SDF".

The LiberationSans is a font that is in the project, and is a font we've used in the past and may be using elsewhere currently, but I am not sure why it's becoming the font material for this text box...

Make sure the font asset itself has the correct atlas texture assigned to it. Most likely it does since it initially starts out ok.

Check if / when you are changing the material or font asset on this object. At some point the incorrect texture gets assigned. Maybe you are using the <material> tag somewhere?

johnnemann

  • Newbie
  • *
  • Posts: 17
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #9 on: December 01, 2018, 02:06:39 PM »
Not using the <material> tag anywhere, but on the panel that seems to cause this issue we're using the <color> tag (as well as the <link> tag...)

And yeah, the font does have the correct atlas texture assigned.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5640
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #10 on: December 01, 2018, 07:10:28 PM »
Looking at the image from your previous post, it is using some instance material. Somewhere in your code, you are accessing the material property while at the same time perhaps changing the font asset. However this is handled, it is the cause of the issue.

BTW: Changing the face or outline color or outline width via the text object property will result in an instance material being created.

Does this text object start out using LiberationSans? Or does it have this other font asset assigned to it by default?
« Last Edit: December 01, 2018, 07:11:59 PM by Stephan B. »

johnnemann

  • Newbie
  • *
  • Posts: 17
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #11 on: December 01, 2018, 08:14:16 PM »
The font is never changed via our code, and we're not accessing the material at all, either. We call ForceMeshUpdate() on the TMP component for the typewriter effect, but that's the most complicated thing our code does with this object. I've attached the results of Find References for this component in VS - maybe you can see something funky we're doing.

We really don't do anything fancy with fonts or materials, all the TMP properties are set by artists in the inspector. I can package up the project for you if you have the time to take a look at it - all our code is only about 3000 lines.


Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5640
Re: "Typewriter effect" leading to weird corrupted characters
« Reply #12 on: December 01, 2018, 09:13:25 PM »
I can package up the project for you if you have the time to take a look at it - all our code is only about 3000 lines.

That would likely be the easiest way to figure out why this is happening.

Just PM me with some private link or something to access the package or something.