From 3bb5ee5648e4438ed51bf586b5d377ae67d12914 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 10 May 2020 00:20:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/API/BaseChart_API.cs | 17 +++++++++++ Runtime/Internal/BaseChart.cs | 3 ++ Runtime/Internal/CoordinateChart.cs | 1 - Runtime/Utility/ChartCached.cs | 1 - Runtime/Utility/ChartDrawer.cs | 1 - Runtime/Utility/XChartsMgr.cs | 46 +++++++++++++++++++++++++++-- 6 files changed, 64 insertions(+), 5 deletions(-) diff --git a/Runtime/API/BaseChart_API.cs b/Runtime/API/BaseChart_API.cs index 81f0e043..f2c3b461 100644 --- a/Runtime/API/BaseChart_API.cs +++ b/Runtime/API/BaseChart_API.cs @@ -18,6 +18,23 @@ namespace XCharts /// public partial class BaseChart { + /// + /// The name of chart. + /// + public string chartName + { + get { return m_ChartName; } + set + { + if (XChartsMgr.Instance.ContainsChart(value)) Debug.LogError("chartName repeated:" + value); + else + { + m_ChartName = value; + m_ChartUUID = value; + } + } + } + public string chartUUID { get { return m_ChartUUID; } } /// /// The theme info. /// diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index 851995af..14eb6055 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -39,6 +39,8 @@ namespace XCharts protected static readonly string s_SerieLabelObjectName = "label"; protected static readonly string s_SerieTitleObjectName = "serie"; + [SerializeField] protected string m_ChartName; + [SerializeField] protected string m_ChartUUID; [SerializeField] protected float m_ChartWidth; [SerializeField] protected float m_ChartHeight; [SerializeField] protected float m_ChartX; @@ -97,6 +99,7 @@ namespace XCharts InitComponent(); m_Series.AnimationReset(); m_Series.AnimationFadeIn(); + XChartsMgr.Instance.AddChart(this); } protected override void Start() diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs index b83c4485..4427958e 100644 --- a/Runtime/Internal/CoordinateChart.cs +++ b/Runtime/Internal/CoordinateChart.cs @@ -17,7 +17,6 @@ namespace XCharts { private static readonly string s_DefaultDataZoom = "datazoom"; private static readonly string s_DefaultAxisName = "name"; - private static readonly string s_DefaultAxisLabel = "label"; [SerializeField] protected Grid m_Grid = Grid.defaultGrid; [SerializeField] protected List m_XAxises = new List(); diff --git a/Runtime/Utility/ChartCached.cs b/Runtime/Utility/ChartCached.cs index 8fb2e672..588ac03a 100644 --- a/Runtime/Utility/ChartCached.cs +++ b/Runtime/Utility/ChartCached.cs @@ -22,7 +22,6 @@ namespace XCharts private static CultureInfo ci = new CultureInfo("en-us");// "en-us", "zh-cn", "ar-iq", "de-de" private static Dictionary s_ColorToStr = new Dictionary(100); private static Dictionary s_SerieLabelName = new Dictionary(1000); - private static Dictionary s_AxisLabelName = new Dictionary(1000); private static Dictionary s_ColorDotStr = new Dictionary(100); private static Dictionary s_XAxisName = new Dictionary(); private static Dictionary s_YAxisName = new Dictionary(); diff --git a/Runtime/Utility/ChartDrawer.cs b/Runtime/Utility/ChartDrawer.cs index 602c2032..2a1f269c 100644 --- a/Runtime/Utility/ChartDrawer.cs +++ b/Runtime/Utility/ChartDrawer.cs @@ -16,7 +16,6 @@ namespace XCharts public static class ChartDrawer { private static readonly Vector2 zeroVector2 = Vector2.zero; - private static readonly Vector3 zeroVector3 = Vector3.zero; private static UIVertex[] vertex = new UIVertex[4]; private static List s_CurvesPosList = new List(); diff --git a/Runtime/Utility/XChartsMgr.cs b/Runtime/Utility/XChartsMgr.cs index a6391c38..404d659e 100644 --- a/Runtime/Utility/XChartsMgr.cs +++ b/Runtime/Utility/XChartsMgr.cs @@ -1,3 +1,4 @@ + /******************************************/ /* */ /* Copyright (c) 2018 monitor1394 */ @@ -8,9 +9,11 @@ using System.Text; using System.Collections; -using UnityEngine; +using System.Collections.Generic; using System.Text.RegularExpressions; +using UnityEngine; using UnityEngine.Networking; +using UnityEngine.SceneManagement; namespace XCharts { @@ -23,6 +26,7 @@ namespace XCharts public string homepage = ""; } + [ExecuteInEditMode] public class XChartsMgr : MonoBehaviour { public const string version = "1.4.0"; @@ -30,7 +34,7 @@ namespace XCharts [SerializeField] private string m_NowVersion; [SerializeField] private string m_NewVersion; - + private Dictionary m_ChartDic = new Dictionary(); private static XChartsMgr m_XCharts; public static XChartsMgr Instance @@ -216,5 +220,43 @@ namespace XCharts return request.isHttpError; } #endif + + void OnEnable() + { + SceneManager.sceneUnloaded += OnSceneLoaded; + } + + private void OnDisable() + { + SceneManager.sceneUnloaded -= OnSceneLoaded; + } + + void OnSceneLoaded(Scene scene) + { + SerieLabelPool.ClearAll(); + } + + public void AddChart(BaseChart chart) + { + //TODO: + } + + public BaseChart GetChart(string uuid) + { + return m_ChartDic[uuid]; + } + + public void RemoveChart(string uuid) + { + if (m_ChartDic.ContainsKey(uuid)) + { + m_ChartDic.Remove(uuid); + } + } + + public bool ContainsChart(string uuid) + { + return m_ChartDic.ContainsKey(uuid); + } } } \ No newline at end of file