Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

[Solved in upcoming patch] Updating text messes up other STM

A topic by ClementCasaRara created Jan 22, 2018 Views: 500 Replies: 8
Viewing posts 1 to 9
(1 edit)

Hi,
We have a randomly consistent issue (:D).
We are using STM to display dialog text for characters in our game using the Unity UI. It worked fine in Unity 5.6 but we recently made the upgrade to 2017.3.0f2 and to the latest version of STM.

I don't know exactly what causes the issue but sometimes when updating the dialog box text, the name of the character (on a separate game object) messes up like if something got recomputed with the font texture and the text was not updated.
Here's the example: all was displayed fine, I updated the TextPanel/TextText STM and suddenly the NamePanel/Text got messed up.
It doesn't happen all the time so it's hard to investigate what causes it or make a test project.
Got any ideas?


Developer (2 edits)

Hey!

I can't believe this bug is back once again... I've been using 2017.1 myself so maybe it's something with 2017.3...?

You're right in the cause of it, it's caused whenever the font atlas gets updated, but STM doesn't rebuild for some reason. STM is subscribed to an event that gets invoked to call Rebuild() whenever its font atlas updates, but for some reason it doesn't always call Rebuild()...? I thought I fixed this 100% before, but I've learned a lot about events in the past few months, so I'll revisit that code and see if it's something to do with that. I am curious if it has something to do with that name box having bolded text, though.


In the meantime, you can avoid font atlas updates altogether if you set your game's font to be non-dymanic. (Go into your font's import settings and change that there) The only downside to non-dynamic fonts is that you can't adjust their quality, and they dont do bold/italics. You can change this in the font's import settings.


I'll look into this again shortly, sorry for the inconvenience!

I don't think it's caused by the bold because it happens on the dialog text sometimes as well (I can check if the dialogs are setting some text to be bold or italic).
Unfortunately we can't really do without bold or italics as we are in the process of testing how "flavorful" we can make our dialog so it's all going to be about bolds, waves and colors. :P

Thanks for the update, keep us posted.


Developer

I really should download 2017.3 to see if I can repro this, cause I've had no luck doing this in 5.3.4 or 2017.1.

The only real things I can think of that will solve this are...

In SuperTextMesh.cs, if you ctrl+F "OnFontTextureRebuilt", you'll find a function that should be getting added to an event called Font.textureRebuilt... this event should be getting added under Init(), and removed under UnInit()... Maybe the problem is that it's getting added too many times, and if the textbox is being enabled/disabled, the event handlers are getting confused?

Send me an email through my website, and I'll send you a beta build! I'll try making it so these handlers are only called once no matter what.

Hmmm...
I was doing something else in another branch and coming back it seems that the issue disappeared. I've tried it 2-3 times now and everything seems fine.
I'll do more tests tomorrow and keep you posted.

Developer

Let me know what you find!

It's always a weird combo of relief and fear when a bug manages to "fix" itself...

(1 edit)

Yeah sorry about that, it's happening againg this morning.
I'll mail you and investigate it more today.

Ok, I think I got it. Basically the issue happens when I enable, disable and re-enable the STM.
The registering of the font rebuild happens on Start and not on OnEnable but the unregistering happens OnDisable. So basically my STMs never re-register again after being re-enabled.
Is there a reason why it is not symmetrical between OnEnable and OnDisable?

Developer

Oh huh, I don't /think/ there should be a reason for that, so that must be it? I could swear it was getting registered under both? I sent you an email with the beta, but I'll get on this in just a bit, sorry!