internal static TMPro.TMP_FontAsset GetTMPFontFromMaterial(Localize cmp, string matName) { string splitChars = " .\\/-[]()"; for (int i = matName.Length - 1; i > 0;) { // Find first valid character while (i > 0 && splitChars.IndexOf(matName[i]) >= 0) { i--; } if (i <= 0) { break; } var fontName = matName.Substring(0, i + 1); var obj = cmp.GetObject <TMPro.TMP_FontAsset>(fontName); if (obj != null) { return(obj); } // skip this word while (i > 0 && splitChars.IndexOf(matName[i]) < 0) { i--; } } return(null); }