Sprite Asset character table is different after a script reload

Hey there, having some trouble as per the title.

TextMeshPro 3.0.4
Video says a thousand words: scalythornyhogget

I’m relying on the name of the character to match the actual image as I reference in code like so:

var index = titleTMP.spriteAsset.GetSpriteIndexFromName(this.logo.name);

But because the character table is showing the incorrect sprite image for the name on script reload, I have to click “Update Sprite Asset” to get the functionality that I want.

The sprite atlas being referenced by the TMP asset does not change, only the character table changes. Very strange.

Anyone else deal with this? Possible to write an editor script that executes after script reload and presses this button for me? :stuck_out_tongue:

Do you get the same behavior using the latest release of TMP which is version 3.2.0-pre.3?

Hello Stephan,

Sorry for the delay in response, I had to upgrade my Unity to 2021 LTS to add TMP 3.2.0. There were some errors in my project I had to sort out but I can confirm that this issue is no longer present.

There is a different issue however I would post this in a separate thread but it seems small enough not to warrant it haha, GetSpriteIndexFromName seems broken?

Here’s my code:

                int index = titleTMP.spriteAsset.GetSpriteIndexFromName(this.logo.name);
                Debug.Log(this.name + " logo: " + this.logo.name + " index: " + index);
                foreach (var g in titleTMP.spriteAsset.spriteGlyphTable) {
                    if (g.sprite.name == this.logo.name) {
                        index = (int)g.index;
                        Debug.Log("sprite: " + g.sprite.name + " index: " + g.index + " atlas: " + g.atlasIndex);
                    }
                }

Here’s the Debug output:

Presumably the for loop I’ve put in is what GetSpriteIndex is doing, but the function returns -1 while the loop finds the appropriate index. The original line worked fine in 3.0.6. Maybe something else has gone wrong in my project.

In any case, my original issue is solved and the for loop gets the right index and that’s all I wanted :slight_smile: Cheers and thanks for the great work.