Text Mesh Pro - Inactive Object Alignment Issue

Hi everyone,

I’m having an issue with the Text Mesh Pro (TMP) asset from the Asset Store. I want to switch all my Text components to TMP, the code I wrote for this works fine, but whenever I turn an inactive object to active my TMP alignment gets reset to Top Left (both in-game and in the Unity Editor). Every other component stays exactly as it was including everything on the TMP component.

Solutions I’ve tried that made no difference:
-I updated to the latest version of TMP and Unity.
-Creating whole new Game Objects and add each component to the new object and delete the old one.
-Setting every object active before I switch the component then turning it inactive again once this is done.
-I have tried this in an empty scene with just 1 TMP component inactive and not a single other script in the entire scene. Which still resulted in the same problem.
-Tried this in an entirely new project with just the TMP asset imported and nothing else. Still have the same issue.

What does work however but is an impossible solution (we have over 9000 text components in the game):
-Changing the text component to TMP, setting the object active so the alignment resets, adjust the alignment manually, turn object inactive again.

I need to be able to have the alignment stay correct even if the object is inactive at the start of the game as I don’t want every text to be shown instantly. I’ve been unable to find anything related online which is odd because I’d think many people would notice this issue.

If you’d like more information just let me know.

Any help would be greatly appreciated.
Thank you!

There is an issue with Prefabs where this can happen. I am assuming you are using the latest release from the Asset Store.

Just for testing, switch the inspector to debug mode and check if the field “Is Alignment Enum Converted” is set? If it is not, change it manually and see if the alignment behaves as expected.

It seems that does indeed fix it. I was unable to set this variable so I used reflection instead.
Thank you for your help!

This was on oversight on my part on legacy code to handle conversion of a previous enum format to a new one. This will be fixed in the next release of TMP.

1 Like

When is this new release is expected?

I am waiting for the next release of Unity 2017.1 to see if some of the changes I have been waiting for make it into that release. Assuming they do and the release comes out this week, then I should be able to get a new release out within the next 7 to 10 days.

Unity 2018.1.0b4, using TMP from Package Manager tagged as 1.0.26, the same bug is here. (My Text is not a prefab)
Ticking “Is Alignment Enum Converted” fixes the problem.
@Stephan_B any information on this?

Also when I’m trying to upgrade to 1.0.27 my whole TMP just gives a lot of errors in the console.

Here’s how to: create disabled UI panel, create TMP in it, set alignment to middle, Play, enable disable panel.

Also: After selecting font asset in U2018.1.0b4/TMP1.0.26 everything below Font Settings just hides and errors in console are thrown.

Also #2: When creating TMP inside enabled gameobject, font is set to LiberationSans/kerning is enabled, if gameobject is disabled font is set to null/kerning is disabled.

After installing this new release, you have to convert the project / assets to this new format as explained in the following post .

Please be sure to follow the recommended upgrade steps outline in that post.

1 Like

I’m running into this issue in 2018.2.0b7 with TMP 1.2.3 (I also tried 1.3.0 but that version doesn’t compile). I am generating the text components from scripts, and as such can not go into Debug mode to tick or untick a private property. I can not use reflection because I need IL2CPP. Specifically, my problem is that I am placing text mesh pro components on disabled tabs (I have a tabbed GUI, with text on different tabs, and all the tabs except the selected one are disabled). I set the alignment from script to Midline Centered, but when I switch to one of the other tabs in play mode the text is Top Left aligned.

Any chance you can provide a simple repro scene that would enable me to reproduce this easily? This repro project / scene can be submitted via the Unity bug reporter. If you do so, please provide the case #.

Alright I made a repro project and submitted it, here’s the case number: 1047771. For now I’ve implemented a workaround I figured out when making the repro, so no rush. I guess it might even be standard expected behavior? The workaround is to simply place the text components while the tabs are active, and only deactivate them afterwards. Seems weird, anyways, that it matters.

Thanks!

I am having this issue as well with Unity 2018.1.1f1. TextMeshPro version is 1.2.3. Ticking “Is Alignment Enum Converted” as mentioned above works, but is inconvenient.

Still have this issue with Unity 2018.2.7f1. Tried a lot of methods but didn’t work out the solution.
I guess we can only make the gameObject active to do further operations…

1 Like

Finally got around to fixing this.

This behavior was the result of some legacy code in TMP.

This behavior has been revised and setting text alignment on disabled text objects will behave correctly in the next release of the TMP UPM package for Unity 2018.3 and up.

The next release will be version 1.4.0 for Unity 2018.3 and 2.0.0 for Unity 2019.1.

2 Likes