From 99d824e3a01d4ba69e106f68d63e1d4f0f71db36 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Fri, 12 Jul 2024 19:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Label`=E5=9C=A8=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=97=B6=E4=BC=9A=E5=A0=86=E7=A7=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Component/Mark/MarkLineHandler.cs | 2 +- Runtime/Internal/Object/ChartLabel.cs | 4 +--- Runtime/Internal/Utilities/ChartHelper.cs | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Runtime/Component/Mark/MarkLineHandler.cs b/Runtime/Component/Mark/MarkLineHandler.cs index 13bf6953..7601a432 100644 --- a/Runtime/Component/Mark/MarkLineHandler.cs +++ b/Runtime/Component/Mark/MarkLineHandler.cs @@ -86,7 +86,7 @@ namespace XCharts.Runtime content, Color.clear, TextAnchor.MiddleCenter); var pos = MarkLineHelper.GetLabelPosition(data); label.SetIconActive(false); - label.SetActive(data.label.show && data.runtimeInGrid); + label.SetActive(data.label.show && data.runtimeInGrid, true); label.SetPosition(pos); data.runtimeLabel = label; }; diff --git a/Runtime/Internal/Object/ChartLabel.cs b/Runtime/Internal/Object/ChartLabel.cs index 7295b59a..c43a6c91 100644 --- a/Runtime/Internal/Object/ChartLabel.cs +++ b/Runtime/Internal/Object/ChartLabel.cs @@ -22,7 +22,6 @@ namespace XCharts.Runtime private Align m_Align = Align.Left; private Image m_IconImage; private bool m_Active = true; - private bool m_WakeActive = true; public Image icon { @@ -57,7 +56,7 @@ namespace XCharts.Runtime protected override void Awake() { raycastTarget = false; - SetActive(m_WakeActive, true); + m_Active = ChartHelper.IsActiveByScale(gameObject); } public void SetTextPadding(TextPadding padding) @@ -203,7 +202,6 @@ namespace XCharts.Runtime public void SetActive(bool flag, bool force = false) { - m_WakeActive = flag; if (m_Active == flag && !force) return; if (ChartHelper.SetActive(gameObject, flag)) { diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index f2ba7d6b..1bfdaba5 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -41,6 +41,23 @@ namespace XCharts.Runtime return s_Builder.ToString(); } + public static bool IsActiveByScale(GameObject gameObject) + { + if (gameObject == null) return false; + return IsActiveByScale(gameObject.transform); + } + + public static bool IsActiveByScale(Image image) + { + if (image == null) return false; + return IsActiveByScale(image.gameObject); + } + + public static bool IsActiveByScale(Transform transform) + { + return transform.localScale != Vector3.zero; + } + public static bool SetActive(GameObject gameObject, bool active) { if (gameObject == null) return false;