修复ChartLabel在TMP下异常报错的问题

This commit is contained in:
monitor1394
2021-07-08 07:04:46 +08:00
parent 8d4a65a002
commit e873709443
2 changed files with 32 additions and 2 deletions

View File

@@ -197,7 +197,7 @@ namespace XCharts
switch (m_Align)
{
case Align.Left:
switch (m_LabelText.text.alignment)
switch (m_LabelText.alignment)
{
case TextAnchor.LowerLeft:
case TextAnchor.UpperLeft:
@@ -217,7 +217,7 @@ namespace XCharts
}
break;
case Align.Right:
switch (m_LabelText.text.alignment)
switch (m_LabelText.alignment)
{
case TextAnchor.LowerLeft:
case TextAnchor.UpperLeft:

View File

@@ -46,6 +46,36 @@ namespace XCharts
}
}
public TextAnchor alignment
{
get
{
#if dUI_TextMeshPro
if (m_TMPText == null) return TextAnchor.MiddleCenter;
switch (m_TMPText.alignment)
{
case TextAlignmentOptions.Bottom: return TextAnchor.LowerCenter;
case TextAlignmentOptions.BottomLeft: return TextAnchor.LowerLeft;
case TextAlignmentOptions.BottomRight: return TextAnchor.LowerRight;
case TextAlignmentOptions.Center: return TextAnchor.MiddleCenter;
case TextAlignmentOptions.Left: return TextAnchor.MiddleLeft;
case TextAlignmentOptions.Right: return TextAnchor.MiddleRight;
case TextAlignmentOptions.Top: return TextAnchor.UpperCenter;
case TextAlignmentOptions.TopLeft: return TextAnchor.UpperLeft;
case TextAlignmentOptions.TopRight: return TextAnchor.UpperRight;
default: return TextAnchor.MiddleCenter;
}
#else
if (m_Text != null) return m_Text.alignment;
else return TextAnchor.MiddleCenter;
#endif
}
set
{
SetAlignment(alignment);
}
}
public ChartText()
{
}