int hashCode = TMP_TextUtilities.GetSimpleHashCode(name);
But the code in UpdateLookupTables that builds the m_NameLookup table uses:
int nameHashCode = TMP_TextUtilities.GetHashCode(m_SpriteCharacterTable[i].name);
if (m_NameLookup.ContainsKey(nameHashCode) == false)
m_NameLookup.Add(nameHashCode, i);
GetSimpleHashCode and GetHashCode generate different hash values, they’re not compatible with each other. Therefore GetSpriteIndexFromName returns -1 always, because the hash value can’t be found in the m_NameLookup table.
Hi @Peter77 , thanks for raising the issue. Could you log a ticket using the Unity Bug Reporter (see this page). This is the best way to ensure we look into it.
I found this thread after doing the same code trace and wondering “why are they using different hashing functions for storage and lookup?”. This bug is still present in 6000.0.35 in 2025. My workaround was to hash the name using TMP_TextUtilities.GetHashCode and then use GetSpriteIndexFromHashcode to find the glyph in the sheet.
I filed a new bug report with an example string on the suspicion that maybe those two hash functions coincidentally returned the same values when the Unity team was trying to repro.