From df0a87c935e74a9f49bc7691d89c1f34176bd93a Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 20 Jun 2022 08:24:00 +0800 Subject: [PATCH 01/32] [bug] fix fadeout animation --- CHANGELOG.md | 3 ++- Runtime/Component/Animation/AnimationStyle.cs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4975545e..de0979f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,11 +54,12 @@ ## master +* (2022.06.20) 修复`Animation`的渐出动画不生效的问题 + ## v3.0.1 * (2022.06.16) 发布`v3.0.1`版本 * (2022.06.16) 修复`Inspector`上部分`foldout`箭头点击无法展开的问题 -* (2022.06.16) 修复`Inspector`上部分`foldout`箭头点击无法展开的问题 * (2022.06.15) 优化`Doc`自动生成,完善代码注释和配置项手册文档 * (2022.06.14) 优化`SerieLabelStyle`,支持动态调整`Icon` * (2022.06.13) 优化`Background`背景设置 diff --git a/Runtime/Component/Animation/AnimationStyle.cs b/Runtime/Component/Animation/AnimationStyle.cs index 00761b44..2e9e6a58 100644 --- a/Runtime/Component/Animation/AnimationStyle.cs +++ b/Runtime/Component/Animation/AnimationStyle.cs @@ -350,9 +350,11 @@ public bool IsFinish() #endif if (!m_Enable || m_IsEnd) return true; - if (IsIndexAnimation()) - return m_CurrDetailProgress > m_DestDetailProgress; + { + if (m_FadeOut) return m_CurrDetailProgress <= m_DestDetailProgress; + else return m_CurrDetailProgress > m_DestDetailProgress; + } if (IsItemAnimation()) return false; return true; From b11e8fcb3ae02e99ff13292f001711bc0ee6a618 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 20 Jun 2022 13:05:44 +0800 Subject: [PATCH 02/32] [bug]fix TextMeshPro compile error --- Runtime/Component/Child/TextStyle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Runtime/Component/Child/TextStyle.cs b/Runtime/Component/Child/TextStyle.cs index d8c4179a..3c0ffbec 100644 --- a/Runtime/Component/Child/TextStyle.cs +++ b/Runtime/Component/Child/TextStyle.cs @@ -149,7 +149,7 @@ public FontStyles tmpFontStyle /// the text alignment of TextMeshPro. /// |TextMeshPro字体对齐方式。 /// - public TextAlignmentOptions tmpFontStyle + public TextAlignmentOptions tmpAlignment { get { return m_TMPAlignment; } set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); } From 5bc14dd37ae7c3558b6d78aa5339c0709d397204 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 20 Jun 2022 13:41:28 +0800 Subject: [PATCH 03/32] [optimaze][tooltip] content rect limit (#202) --- CHANGELOG.md | 2 ++ Runtime/Component/Tooltip/TooltipHelper.cs | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de0979f2..cb879504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,8 @@ ## master +* (2022.06.20) 优化`Tooltip`的边界限制 (#202) +* (2022.06.20) 修复`TextMeshPro`开启时编译错误 * (2022.06.20) 修复`Animation`的渐出动画不生效的问题 ## v3.0.1 diff --git a/Runtime/Component/Tooltip/TooltipHelper.cs b/Runtime/Component/Tooltip/TooltipHelper.cs index 9e099bd9..ce389f64 100644 --- a/Runtime/Component/Tooltip/TooltipHelper.cs +++ b/Runtime/Component/Tooltip/TooltipHelper.cs @@ -64,13 +64,18 @@ public static void LimitInRect(Tooltip tooltip, Rect chartRect) var pos = tooltip.view.GetTargetPos(); if (pos.x + tooltip.context.width > chartRect.x + chartRect.width) { - //pos.x = chartRect.x + chartRect.width - tooltip.context.width; - pos.x = pos.x - tooltip.context.width - tooltip.offset.x; + pos.x = tooltip.context.pointer.x - tooltip.context.width - tooltip.offset.x; + } + else if (pos.x < chartRect.x) + { + pos.x = tooltip.context.pointer.x - tooltip.context.width + Mathf.Abs(tooltip.offset.x); } if (pos.y - tooltip.context.height < chartRect.y) { pos.y = chartRect.y + tooltip.context.height; } + if (pos.y > chartRect.y + chartRect.height) + pos.y = chartRect.y + chartRect.height; tooltip.UpdateContentPos(pos); } From 8a6253621bfe351b9a2d001733b37783d41ca5f7 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 21 Jun 2022 08:15:48 +0800 Subject: [PATCH 04/32] [optimize][textstyle] support sprite asset of TextMeshPro (#201) --- CHANGELOG.md | 1 + Editor/ChildComponents/TextStyleDrawer.cs | 1 + Runtime/Component/Child/TextStyle.cs | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb879504..c0df51cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ ## master +* (2022.06.21) 增加`TextStyle`对`TextMeshPro`的`Sprite Asset`支持 (#201) * (2022.06.20) 优化`Tooltip`的边界限制 (#202) * (2022.06.20) 修复`TextMeshPro`开启时编译错误 * (2022.06.20) 修复`Animation`的渐出动画不生效的问题 diff --git a/Editor/ChildComponents/TextStyleDrawer.cs b/Editor/ChildComponents/TextStyleDrawer.cs index edaf6d0e..70f44b6f 100644 --- a/Editor/ChildComponents/TextStyleDrawer.cs +++ b/Editor/ChildComponents/TextStyleDrawer.cs @@ -29,6 +29,7 @@ public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) PropertyField(prop, "m_LineSpacing"); #if dUI_TextMeshPro PropertyField(prop, "m_TMPFontStyle"); + PropertyField(prop, "m_TMPSpriteAsset"); PropertyField(prop, "m_TMPAlignment"); #else PropertyField(prop, "m_FontStyle"); diff --git a/Runtime/Component/Child/TextStyle.cs b/Runtime/Component/Child/TextStyle.cs index 3c0ffbec..1630d47d 100644 --- a/Runtime/Component/Child/TextStyle.cs +++ b/Runtime/Component/Child/TextStyle.cs @@ -28,6 +28,7 @@ public class TextStyle : ChildComponent [SerializeField] private TMP_FontAsset m_TMPFont; [SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal; [SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left; + [SerializeField] private TMP_SpriteAsset m_TMPSpriteAsset; #endif public bool show { @@ -154,6 +155,15 @@ public TextAlignmentOptions tmpAlignment get { return m_TMPAlignment; } set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); } } + /// + /// the sprite asset of TextMeshPro. + /// |TextMeshPro的Sprite Asset。 + /// + public TMP_SpriteAsset tmpSpriteAsset + { + get { return m_TMPSpriteAsset; } + set { if (PropertyUtil.SetClass(ref m_TMPSpriteAsset, value)) SetComponentDirty(); } + } #endif public TextStyle() { } @@ -198,6 +208,7 @@ public void Copy(TextStyle textStyle) #if dUI_TextMeshPro m_TMPFont = textStyle.tmpFont; m_TMPFontStyle = textStyle.tmpFontStyle; + m_TMPSpriteAsset = textStyle.tmpSpriteAsset; #endif } From 7c07499e447f716b43ac9b45fbf59a100bf223f8 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Fri, 24 Jun 2022 22:15:49 +0800 Subject: [PATCH 05/32] [optimize][legend] support background and padding --- Runtime/Component/Legend/Legend.cs | 20 +++++++++++++++ Runtime/Component/Legend/LegendContext.cs | 3 +++ Runtime/Component/Legend/LegendHandler.cs | 3 +++ Runtime/Component/Legend/LegendHelper.cs | 30 +++++++++++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/Runtime/Component/Legend/Legend.cs b/Runtime/Component/Legend/Legend.cs index 4c59156f..c905508e 100644 --- a/Runtime/Component/Legend/Legend.cs +++ b/Runtime/Component/Legend/Legend.cs @@ -80,6 +80,8 @@ public enum SelectedMode [SerializeField] private List m_Data = new List(); [SerializeField] private List m_Icons = new List(); [SerializeField] private List m_Colors = new List(); + [SerializeField] protected ImageStyle m_Background = new ImageStyle() { show = false }; + [SerializeField] protected Padding m_Padding = new Padding(); public LegendContext context = new LegendContext(); @@ -213,6 +215,24 @@ public LabelStyle labelStyle set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); } } /// + /// the sytle of background. + /// |背景图样式。 + /// + public ImageStyle background + { + get { return m_Background; } + set { if (PropertyUtil.SetClass(ref m_Background, value)) SetAllDirty(); } + } + /// + /// the paddinng of item and background. + /// |图例标记和背景的间距。 + /// + public Padding padding + { + get { return m_Padding; } + set { if (PropertyUtil.SetClass(ref m_Padding, value)) SetAllDirty(); } + } + /// /// Data array of legend. An array item is usually a name representing string. (If it is a pie chart, /// it could also be the name of a single data in the pie chart) of a series. /// |If data is not specified, it will be auto collected from series. diff --git a/Runtime/Component/Legend/LegendContext.cs b/Runtime/Component/Legend/LegendContext.cs index 9bead405..12cc5688 100644 --- a/Runtime/Component/Legend/LegendContext.cs +++ b/Runtime/Component/Legend/LegendContext.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; namespace XCharts.Runtime { @@ -14,6 +15,7 @@ public class LegendContext : MainComponentContext /// 运行时图例的总高度 /// public float height { get; internal set; } + public Vector2 center { get; internal set; } /// /// the button list of legend. /// |图例按钮列表。 @@ -27,5 +29,6 @@ public class LegendContext : MainComponentContext /// 单列高度 /// internal float eachHeight { get; set; } + public Image background { get; set; } } } \ No newline at end of file diff --git a/Runtime/Component/Legend/LegendHandler.cs b/Runtime/Component/Legend/LegendHandler.cs index 75b71615..724d5d06 100644 --- a/Runtime/Component/Legend/LegendHandler.cs +++ b/Runtime/Component/Legend/LegendHandler.cs @@ -56,6 +56,9 @@ private void InitLegend(Legend legend) legend.gameObject = legendObject; legendObject.hideFlags = chart.chartHideFlags; SeriesHelper.UpdateSerieNameList(chart, ref chart.m_LegendRealShowName); + legend.context.background = ChartHelper.AddIcon("background", legendObject.transform, 0, 0); + legend.context.background.transform.SetSiblingIndex(0); + ChartHelper.SetBackground(legend.context.background, legend.background); List datas; if (legend.show && legend.data.Count > 0) { diff --git a/Runtime/Component/Legend/LegendHelper.cs b/Runtime/Component/Legend/LegendHelper.cs index 422eb2ab..f51f9cfa 100644 --- a/Runtime/Component/Legend/LegendHelper.cs +++ b/Runtime/Component/Legend/LegendHelper.cs @@ -52,6 +52,7 @@ public static LegendItem AddLegendItem(BaseChart chart, Legend legend, int i, st var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta); var img = ChartHelper.GetOrAddComponent(btnObj); img.color = Color.clear; + img.raycastTarget = true; ChartHelper.GetOrAddComponent