修复TextLimit在开启TextMeshPro后无效的问题 (#301)

This commit is contained in:
monitor1394
2024-01-27 13:35:47 +08:00
parent d93f7830de
commit c987cb1ef7
2 changed files with 6 additions and 2 deletions

View File

@@ -70,6 +70,7 @@ slug: /changelog
## master
* (2024.01.27) 修复`TextLimit`在开启`TextMeshPro`后无效的问题 (#301)
* (2024.01.24) 增加`Bar`支持X轴和Y轴都为`Category`类目轴
* (2024.01.23) 增加`{y}`通配符用于获取Y轴的类目名
* (2024.01.23) 增加`Line`支持X轴和Y轴都为`Category`类目轴

View File

@@ -263,9 +263,12 @@ namespace XCharts.Runtime
public float GetPreferredWidth(string content)
{
#if dUI_TextMeshPro
if (m_TMPText != null) return 0; // TODO:
if (m_TMPText != null && !string.IsNullOrEmpty(content))
{
return m_TMPText.GetPreferredValues(content).x;
}
#else
if (m_Text != null)
if (m_Text != null && !string.IsNullOrEmpty(content))
{
var tg = m_Text.cachedTextGeneratorForLayout;
var setting = m_Text.GetGenerationSettings(Vector2.zero);