diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d30d8e9..4b1a9536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # 更新日志 -* (2020.05.18) 增加`chartName`属性,可通过`XChartMgr.Instance.GetChart(chartName)`获取图表 +* (2020.05.18) 增加`chartName`属性可指定图表的别称,可通过`XChartMgr.Instance.GetChart(chartName)`获取图表 * (2020.05.16) 增加部分鼠标事件回调 * (2020.05.15) 优化自带例子,`Demo`改名为`Example` * (2020.05.13) 增加`Serie`的`large`和`largeThreshold`参数配置折线图和柱状图的性能模式 diff --git a/Runtime/BarChart.cs b/Runtime/BarChart.cs index 07fd575b..389d7c1a 100644 --- a/Runtime/BarChart.cs +++ b/Runtime/BarChart.cs @@ -16,12 +16,6 @@ namespace XCharts public class BarChart : CoordinateChart { - protected override void Awake() - { - base.Awake(); - XChartsMgr.Instance.AddChart(this); - } - #if UNITY_EDITOR protected override void Reset() { diff --git a/Runtime/Helper/CheckHelper.cs b/Runtime/Helper/CheckHelper.cs index 37d36a3e..f1100f2d 100644 --- a/Runtime/Helper/CheckHelper.cs +++ b/Runtime/Helper/CheckHelper.cs @@ -19,6 +19,7 @@ namespace XCharts { var sb = ChartHelper.sb; sb.Length = 0; + CheckName(chart, sb); CheckSize(chart, sb); CheckTheme(chart, sb); CheckTitle(chart, sb); @@ -28,6 +29,16 @@ namespace XCharts return sb.ToString(); } + private static void CheckName(BaseChart chart, StringBuilder sb) + { + if (string.IsNullOrEmpty(chart.chartName)) return; + var list = XChartsMgr.Instance.GetCharts(chart.chartName); + if (list.Count > 1) + { + sb.AppendFormat("warning:chart name is repeated: {0}\n", chart.chartName); + } + } + private static void CheckSize(BaseChart chart, StringBuilder sb) { if (chart.chartWidth == 0 || chart.chartHeight == 0) diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index e83b4e12..53e798a5 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -52,33 +52,33 @@ namespace XCharts [SerializeField] protected Series m_Series = Series.defaultSeries; [SerializeField] protected Settings m_Settings = new Settings(); - [NonSerialized] protected Action m_OnCustomDrawCallback; - [NonSerialized] protected Action m_OnPointerClick; - [NonSerialized] protected Action m_OnPointerDown; - [NonSerialized] protected Action m_OnPointerUp; - [NonSerialized] protected Action m_OnPointerEnter; - [NonSerialized] protected Action m_OnPointerExit; - [NonSerialized] protected Action m_OnBeginDrag; - [NonSerialized] protected Action m_OnDrag; - [NonSerialized] protected Action m_OnEndDrag; - [NonSerialized] protected Action m_OnScroll; + protected Action m_OnCustomDrawCallback; + protected Action m_OnPointerClick; + protected Action m_OnPointerDown; + protected Action m_OnPointerUp; + protected Action m_OnPointerEnter; + protected Action m_OnPointerExit; + protected Action m_OnBeginDrag; + protected Action m_OnDrag; + protected Action m_OnEndDrag; + protected Action m_OnScroll; - [NonSerialized] protected Vector3 m_ChartPosition = Vector3.zero; - [NonSerialized] protected Vector2 m_ChartMinAnchor; - [NonSerialized] protected Vector2 m_ChartMaxAnchor; - [NonSerialized] protected Vector2 m_ChartPivot; - [NonSerialized] protected Vector2 m_ChartSizeDelta; - [NonSerialized] protected Rect m_ChartRect = new Rect(0, 0, 0, 0); + protected Vector3 m_ChartPosition = Vector3.zero; + protected Vector2 m_ChartMinAnchor; + protected Vector2 m_ChartMaxAnchor; + protected Vector2 m_ChartPivot; + protected Vector2 m_ChartSizeDelta; + protected Rect m_ChartRect = new Rect(0, 0, 0, 0); - [NonSerialized] protected bool m_RefreshChart = false; - [NonSerialized] protected bool m_RefreshLabel = false; - [NonSerialized] protected bool m_ReinitLabel = false; - [NonSerialized] protected bool m_ReinitTitle = false; - [NonSerialized] protected bool m_CheckAnimation = false; - [NonSerialized] protected bool m_IsPlayingAnimation = false; - [NonSerialized] protected List m_LegendRealShowName = new List(); - [NonSerialized] protected GameObject m_SerieLabelRoot; - [NonSerialized] protected bool m_ForceOpenRaycastTarget; + protected bool m_RefreshChart = false; + protected bool m_RefreshLabel = false; + protected bool m_ReinitLabel = false; + protected bool m_ReinitTitle = false; + protected bool m_CheckAnimation = false; + protected bool m_IsPlayingAnimation = false; + protected List m_LegendRealShowName = new List(); + protected GameObject m_SerieLabelRoot; + protected bool m_ForceOpenRaycastTarget; protected Vector2 chartAnchorMax { get { return m_ChartMinAnchor; } } protected Vector2 chartAnchorMin { get { return m_ChartMaxAnchor; } }