diff --git a/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs b/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs index 1659321e..b2ba8d7a 100644 --- a/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs +++ b/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs @@ -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: diff --git a/Assets/XCharts/Runtime/Internal/Object/ChartText.cs b/Assets/XCharts/Runtime/Internal/Object/ChartText.cs index 007ce74d..2e2edf67 100644 --- a/Assets/XCharts/Runtime/Internal/Object/ChartText.cs +++ b/Assets/XCharts/Runtime/Internal/Object/ChartText.cs @@ -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() { }