From 333dfb8e376f988cd04ce4520db370cf2134ab83 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 4 Dec 2024 08:19:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`UIText`=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 3 +++ Runtime/Internal/Utilities/ChartHelper.cs | 4 ++-- Runtime/Internal/Utilities/UIHelper.cs | 28 +++++++++++------------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 8743b88d..93477538 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,9 @@ slug: /changelog ## master +* (2024.11.04) 增加`UIText`扩展组件 +* (2024.12.04) 删除`TextStyle`的无用配置项`tmpAlignment` + ## v3.12.1 版本要点: diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index fb67ad55..4e1d72b7 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -319,7 +319,7 @@ namespace XCharts.Runtime chartText.SetActive(textStyle.show); RectTransform rect = EnsureComponent(txtObj); - rect.localPosition = Vector3.zero; + rect.anchoredPosition3D = Vector3.zero; rect.sizeDelta = sizeDelta; rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; @@ -492,7 +492,7 @@ namespace XCharts.Runtime return label; } - private static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax, + public static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax, out Vector2 pivot) { switch (alignment) diff --git a/Runtime/Internal/Utilities/UIHelper.cs b/Runtime/Internal/Utilities/UIHelper.cs index 54f9ff25..592df19c 100644 --- a/Runtime/Internal/Utilities/UIHelper.cs +++ b/Runtime/Internal/Utilities/UIHelper.cs @@ -27,27 +27,27 @@ namespace XCharts.Runtime borderWidth, borderColor); } - internal static void InitBackground(UIComponent table) + internal static void InitBackground(UIComponent component) { - if (table.background.show == false || - (table.background.image == null && ChartHelper.IsClearColor(table.background.imageColor))) + if (component.background.show == false || + (component.background.image == null && ChartHelper.IsClearColor(component.background.imageColor))) { - ChartHelper.DestoryGameObject(table.transform, "Background"); + ChartHelper.DestoryGameObject(component.transform, "Background"); return; } - var sizeDelta = table.background.imageWidth > 0 && table.background.imageHeight > 0 ? - new Vector2(table.background.imageWidth, table.background.imageHeight) : - table.graphSizeDelta; - var backgroundObj = ChartHelper.AddObject("Background", table.transform, table.graphMinAnchor, - table.graphMaxAnchor, table.graphPivot, sizeDelta); - backgroundObj.hideFlags = table.chartHideFlags; + var sizeDelta = component.background.imageWidth > 0 && component.background.imageHeight > 0 ? + new Vector2(component.background.imageWidth, component.background.imageHeight) : + component.graphSizeDelta; + var backgroundObj = ChartHelper.AddObject("Background", component.transform, component.graphMinAnchor, + component.graphMaxAnchor, component.graphPivot, sizeDelta); + backgroundObj.hideFlags = component.chartHideFlags; var backgroundImage = ChartHelper.EnsureComponent(backgroundObj); - ChartHelper.UpdateRectTransform(backgroundObj, table.graphMinAnchor, - table.graphMaxAnchor, table.graphPivot, sizeDelta); - ChartHelper.SetBackground(backgroundImage, table.background); + ChartHelper.UpdateRectTransform(backgroundObj, component.graphMinAnchor, + component.graphMaxAnchor, component.graphPivot, sizeDelta); + ChartHelper.SetBackground(backgroundImage, component.background); backgroundObj.transform.SetSiblingIndex(0); - backgroundObj.SetActive(table.background.show && table.background.image != null); + backgroundObj.SetActive(component.background.show && component.background.image != null); } } } \ No newline at end of file