diff --git a/Editor/Utilities/ChartEditorHelper.cs b/Editor/Utilities/ChartEditorHelper.cs index 647e7166..859b5a9e 100644 --- a/Editor/Utilities/ChartEditorHelper.cs +++ b/Editor/Utilities/ChartEditorHelper.cs @@ -539,7 +539,7 @@ namespace XCharts.Editor return HEADER_HEIGHT; } - internal static bool DrawHeader(string title, bool state, bool drawBackground, SerializedProperty activeField, + public static bool DrawHeader(string title, bool state, bool drawBackground, SerializedProperty activeField, Action drawCallback, params HeaderMenuInfo[] menus) { var rect = GUILayoutUtility.GetRect(1f, HEADER_HEIGHT); diff --git a/Editor/Widgets.meta b/Editor/Widgets.meta deleted file mode 100644 index cd483900..00000000 --- a/Editor/Widgets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b92d575a960f54e9a9417cca092d1e11 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/Widgets/ProgressBarEditor.cs b/Editor/Widgets/ProgressBarEditor.cs deleted file mode 100644 index 112269b4..00000000 --- a/Editor/Widgets/ProgressBarEditor.cs +++ /dev/null @@ -1,51 +0,0 @@ -using UnityEditor; -using XCharts.Runtime; - -namespace XCharts.Editor -{ - [CustomEditor(typeof(ProgressBar), false)] - public class ProgressBarEditor : UnityEditor.Editor - { - - [MenuItem("XCharts/ProgressBar", priority = 200)] - [MenuItem("GameObject/XCharts/ProgressBar", priority = 200)] - public static void AddPyramidChart() - { - XChartsEditor.AddChart("ProgressBar"); - } - - protected SerializedProperty m_Script; - protected SerializedProperty m_Value; - protected SerializedProperty m_BackgroundColor; - protected SerializedProperty m_StartColor; - protected SerializedProperty m_EndColor; - protected SerializedProperty m_CornerRadius; - - protected virtual void OnEnable() - { - m_Script = serializedObject.FindProperty("m_Script"); - m_Value = serializedObject.FindProperty("m_Value"); - m_BackgroundColor = serializedObject.FindProperty("m_BackgroundColor"); - m_StartColor = serializedObject.FindProperty("m_StartColor"); - m_EndColor = serializedObject.FindProperty("m_EndColor"); - m_CornerRadius = serializedObject.FindProperty("m_CornerRadius"); - } - - public override void OnInspectorGUI() - { - serializedObject.Update(); - OnStartInspectorGUI(); - serializedObject.ApplyModifiedProperties(); - } - - protected virtual void OnStartInspectorGUI() - { - EditorGUILayout.PropertyField(m_Script); - EditorGUILayout.PropertyField(m_BackgroundColor); - EditorGUILayout.PropertyField(m_StartColor); - EditorGUILayout.PropertyField(m_EndColor); - EditorGUILayout.PropertyField(m_Value); - EditorGUILayout.PropertyField(m_CornerRadius); - } - } -} \ No newline at end of file diff --git a/Editor/Widgets/ProgressBarEditor.cs.meta b/Editor/Widgets/ProgressBarEditor.cs.meta deleted file mode 100644 index 37bbd287..00000000 --- a/Editor/Widgets/ProgressBarEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 17cd5e3604edc43e5b7b6bfc3c71857b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/Windows/XChartsEditor.cs b/Editor/Windows/XChartsEditor.cs index ed33ec98..d72e84ff 100644 --- a/Editor/Windows/XChartsEditor.cs +++ b/Editor/Windows/XChartsEditor.cs @@ -56,24 +56,30 @@ namespace XCharts.Editor } public static T AddChart(string chartName) where T : BaseChart + { + XCThemeMgr.CheckReloadTheme(); + return AddGraph(chartName); + } + + public static T AddGraph(string graphName) where T : BaseGraph { var parent = GetParent(); if (parent == null) return null; XCThemeMgr.CheckReloadTheme(); - var chart = new GameObject(); - chart.name = GetName(parent, chartName); - chart.layer = LayerMask.NameToLayer("UI"); - var t = chart.AddComponent(); - chart.transform.SetParent(parent); - chart.transform.localScale = Vector3.one; - chart.transform.localPosition = Vector3.zero; - chart.transform.localRotation = Quaternion.Euler(0, 0, 0); - var rect = chart.GetComponent(); + var obj = new GameObject(); + obj.name = GetName(parent, graphName); + obj.layer = LayerMask.NameToLayer("UI"); + var t = obj.AddComponent(); + obj.transform.SetParent(parent); + obj.transform.localScale = Vector3.one; + obj.transform.localPosition = Vector3.zero; + obj.transform.localRotation = Quaternion.Euler(0, 0, 0); + var rect = obj.GetComponent(); rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); rect.pivot = new Vector2(0.5f, 0.5f); - Selection.activeGameObject = chart; - EditorUtility.SetDirty(chart); + Selection.activeGameObject = obj; + EditorUtility.SetDirty(obj); return t; } diff --git a/Runtime/Component/Background/Background.cs b/Runtime/Component/Background/Background.cs index 68f212ce..bd230cf4 100644 --- a/Runtime/Component/Background/Background.cs +++ b/Runtime/Component/Background/Background.cs @@ -6,8 +6,7 @@ namespace XCharts.Runtime { /// /// Background component. - /// | - /// 背景组件。 + /// |背景组件。 /// [Serializable] [DisallowMultipleComponent] @@ -27,7 +26,7 @@ namespace XCharts.Runtime public bool show { get { return m_Show; } - internal set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } + set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } } /// /// the image of background. diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index 7f1afd17..0815e8dc 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -18,6 +18,7 @@ namespace XCharts.Runtime [SerializeField] protected string m_ChartName; [SerializeField] protected ThemeStyle m_Theme = new ThemeStyle(); [SerializeField] protected Settings m_Settings; + [SerializeField] protected DebugInfo m_DebugInfo = new DebugInfo(); #pragma warning disable 0414 [SerializeField][ListForComponent(typeof(AngleAxis))] private List m_AngleAxes = new List(); @@ -67,6 +68,8 @@ namespace XCharts.Runtime public List components { get { return m_Components; } } public List series { get { return m_Series; } } + public DebugInfo debug { get { return m_DebugInfo; } } + public override HideFlags chartHideFlags { get { return m_DebugInfo.showAllChartObject ? HideFlags.None : HideFlags.HideInHierarchy; } } protected float m_ChartWidth; protected float m_ChartHeight; diff --git a/Runtime/Internal/BaseGraph.API.cs b/Runtime/Internal/BaseGraph.API.cs index f2c9c945..dae4f8da 100644 --- a/Runtime/Internal/BaseGraph.API.cs +++ b/Runtime/Internal/BaseGraph.API.cs @@ -36,6 +36,11 @@ namespace XCharts.Runtime /// public Vector3 graphPosition { get { return m_GraphPosition; } } public Rect graphRect { get { return m_GraphRect; } } + public Vector2 graphSizeDelta { get { return m_GraphSizeDelta; } } + public Vector2 graphPivot { get { return m_GraphPivot; } } + public Vector2 graphMinAnchor { get { return m_GraphMinAnchor; } } + public Vector2 graphMaxAnchor { get { return m_GraphMaxAnchor; } } + public Vector2 graphAnchoredPosition { get { return m_GraphAnchoredPosition; } } /// /// The postion of pointer. /// |鼠标位置。 diff --git a/Runtime/Internal/BaseGraph.cs b/Runtime/Internal/BaseGraph.cs index f5e52e10..a74da86a 100644 --- a/Runtime/Internal/BaseGraph.cs +++ b/Runtime/Internal/BaseGraph.cs @@ -10,9 +10,7 @@ namespace XCharts.Runtime IPointerEnterHandler, IPointerExitHandler, IBeginDragHandler, IPointerClickHandler, IDragHandler, IEndDragHandler, IScrollHandler { - [SerializeField] protected bool m_EnableTextMeshPro = false; - [SerializeField] protected DebugInfo m_DebugInfo = new DebugInfo(); protected Painter m_Painter; protected int m_SiblingIndex; @@ -45,11 +43,8 @@ namespace XCharts.Runtime protected Action m_OnEndDrag; protected Action m_OnScroll; - protected Vector2 graphAnchorMax { get { return m_GraphMinAnchor; } } - protected Vector2 graphAnchorMin { get { return m_GraphMaxAnchor; } } - protected Vector2 graphPivot { get { return m_GraphPivot; } } - public HideFlags chartHideFlags { get { return m_DebugInfo.showAllChartObject ? HideFlags.None : HideFlags.HideInHierarchy; } } - public DebugInfo debug { get { return m_DebugInfo; } } + public virtual HideFlags chartHideFlags { get { return HideFlags.None; } } + private ScrollRect m_ScrollRect; public Painter painter { get { return m_Painter; } } @@ -128,8 +123,7 @@ namespace XCharts.Runtime } #if UNITY_EDITOR - protected override void Reset() - { } + protected override void Reset() { } protected override void OnValidate() { @@ -253,16 +247,14 @@ namespace XCharts.Runtime m_RefreshChart = true; } - protected virtual void OnLocalPositionChanged() - { } + protected virtual void OnLocalPositionChanged() { } protected virtual void OnDrawPainterBase(VertexHelper vh, Painter painter) { DrawPainterBase(vh); } - protected virtual void DrawPainterBase(VertexHelper vh) - { } + protected virtual void DrawPainterBase(VertexHelper vh) { } public virtual void OnPointerClick(PointerEventData eventData) { diff --git a/Runtime/Widgets/ProgressBar.cs b/Runtime/Widgets/ProgressBar.cs deleted file mode 100644 index 8efac8a0..00000000 --- a/Runtime/Widgets/ProgressBar.cs +++ /dev/null @@ -1,51 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; -using XUGL; - -namespace XCharts.Runtime -{ - [ExecuteInEditMode] - [RequireComponent(typeof(RectTransform))] - [DisallowMultipleComponent] - public class ProgressBar : BaseChart - { - [SerializeField][Range(0f, 1f)] private float m_Value = 0.5f; - [SerializeField] private Color m_BackgroundColor = new Color32(255, 233, 233, 255); - [SerializeField] private Color m_StartColor = Color.blue; - [SerializeField] private Color m_EndColor = Color.red; - [SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 }; - - public float value { get { return m_Value; } set { m_Value = value; SetVerticesDirty(); } } - public Color32 backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; SetVerticesDirty(); } } - public Color32 startColor { get { return m_StartColor; } set { m_StartColor = value; SetVerticesDirty(); } } - public Color32 endColor { get { return m_EndColor; } set { m_EndColor = value; SetVerticesDirty(); } } - public float[] cornerRadius { get { return m_CornerRadius; } set { m_CornerRadius = value; SetVerticesDirty(); } } - -#if UNITY_EDITOR - protected override void Reset() - { - base.Reset(); - var title = GetOrAddChartComponent(); - title.text = "ProgressBar"; - title.show = false; - SetSize(580, 4); - RemoveData(); - } -#endif - - protected override void OnDrawPainterBase(VertexHelper vh, Painter painter) - { - vh.Clear(); - var centerPos = new Vector3(chartPosition.x + m_ChartWidth / 2, chartPosition.y + m_ChartHeight / 2); - UGL.DrawRoundRectangle(vh, centerPos, m_ChartWidth, m_ChartHeight, m_BackgroundColor, m_BackgroundColor, - 0, m_CornerRadius, true); - - var valueWidth = m_Value * m_ChartWidth; - var valuePos = new Vector3(chartPosition.x + valueWidth / 2, centerPos.y); - var endColor = Color.Lerp(m_StartColor, m_EndColor, m_Value); - UGL.DrawRoundRectangle(vh, valuePos, valueWidth, m_ChartHeight, m_StartColor, endColor, 0, - m_CornerRadius, true); - } - - } -} \ No newline at end of file diff --git a/Runtime/Widgets/ProgressBar.cs.meta b/Runtime/Widgets/ProgressBar.cs.meta deleted file mode 100644 index 1b34a707..00000000 --- a/Runtime/Widgets/ProgressBar.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cd18af5634e604a3c97fb1ff0fc5d682 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: