Skip to content

Commit

Permalink
修复TextLimit在开启TextMeshPro后无效的问题 (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
monitor1394 committed Jan 27, 2024
1 parent c987cb1 commit bc75865
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions Runtime/Internal/Object/ChartText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,25 +299,18 @@ public float GetPreferredHeight()

public string GetPreferredText(string content, string suffix, float maxWidth)
{
#if dUI_TextMeshPro
if (m_TMPText != null) return content; // TODO:
#else
if (m_Text != null)
var sourWid = GetPreferredWidth(content);
if (sourWid < maxWidth) return content;
var suffixWid = GetPreferredWidth(suffix);
var textWid = maxWidth - 1.3f * suffixWid;
for (int i = content.Length; i > 0; i--)
{
var sourWid = GetPreferredWidth(content);
if (sourWid < maxWidth) return content;
var suffixWid = GetPreferredWidth(suffix);
var textWid = maxWidth - 1.3f * suffixWid;
for (int i = content.Length; i > 0; i--)
var temp = content.Substring(0, i);
if (GetPreferredWidth(temp) < textWid)
{
var temp = content.Substring(0, i);
if (GetPreferredWidth(temp) < textWid)
{
return temp + suffix;
}
return temp + suffix;
}
}
#endif
return string.Empty;
}

Expand Down

0 comments on commit bc75865

Please sign in to comment.