From 1f49877b5ed3b36f58c7d00ff2c5281754899c73 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 12 Jan 2021 13:11:15 +0800 Subject: [PATCH] XCharts 2.0 --- Editor/Utility/ChartEditorHelper.cs | 41 +++++++++++++-------- Examples/Runtime/Example12_CustomDrawing.cs | 4 +- README.md | 21 +++++------ 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/Editor/Utility/ChartEditorHelper.cs b/Editor/Utility/ChartEditorHelper.cs index 0f3835d9..64c2e72e 100644 --- a/Editor/Utility/ChartEditorHelper.cs +++ b/Editor/Utility/ChartEditorHelper.cs @@ -17,12 +17,21 @@ public class ChartEditorHelper public const float ARROW_WIDTH = 13; public const float GAP_WIDTH = 0; #endif - public static GUIStyle headerStyle = EditorStyles.boldLabel; - public static GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout) + + private class Styles { - font = headerStyle.font, - fontStyle = headerStyle.fontStyle, - }; + public static readonly GUIStyle headerStyle = EditorStyles.boldLabel; + public static readonly GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout) + { + font = headerStyle.font, + fontStyle = headerStyle.fontStyle, + }; + public static readonly GUIContent iconAdd = EditorGUIUtility.TrIconContent("Toolbar Plus", "Add"); + public static readonly GUIContent iconRemove = EditorGUIUtility.TrIconContent("Toolbar Minus", "Remove"); + public static readonly GUIContent iconUp = new GUIContent("↑", "Up"); + public static readonly GUIContent iconDown = new GUIContent("↓", "Down"); + public static readonly GUIStyle invisibleButton = "InvisibleButton"; + } public static void SecondField(Rect drawRect, SerializedProperty prop) { @@ -126,7 +135,7 @@ public class ChartEditorHelper float defaultWidth = drawRect.width; float defaultX = drawRect.x; drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH; - moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? foldoutStyle : EditorStyles.foldout); + moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? Styles.foldoutStyle : EditorStyles.foldout); MakeBool(drawRect, prop); drawRect.width = defaultWidth; drawRect.x = defaultX; @@ -139,7 +148,7 @@ public class ChartEditorHelper float defaultWidth = drawRect.width; float defaultX = drawRect.x; drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH; - moduleToggle[key] = EditorGUI.Foldout(drawRect, moduleToggle[key], content, bold ? foldoutStyle : EditorStyles.foldout); + moduleToggle[key] = EditorGUI.Foldout(drawRect, moduleToggle[key], content, bold ? Styles.foldoutStyle : EditorStyles.foldout); if (prop != null) { if (prop.propertyType == SerializedPropertyType.Boolean) @@ -218,7 +227,7 @@ public class ChartEditorHelper drawRect.width = EditorGUIUtility.labelWidth; #endif var displayName = string.IsNullOrEmpty(moduleName) ? prop.displayName : moduleName; - toggle = EditorGUI.Foldout(drawRect, toggle, displayName, bold ? foldoutStyle : EditorStyles.foldout); + toggle = EditorGUI.Foldout(drawRect, toggle, displayName, bold ? Styles.foldoutStyle : EditorStyles.foldout); if (moduleToggle[key] != toggle) { @@ -268,7 +277,7 @@ public class ChartEditorHelper { iconRect.x += BLOCK_WIDTH; } - if (GUI.Button(iconRect, new GUIContent("+", "add"))) + if (GUI.Button(iconRect, Styles.iconAdd, Styles.invisibleButton)) { if (listProp.displayName.Equals("Series")) { @@ -336,7 +345,7 @@ public class ChartEditorHelper { iconRect.x += BLOCK_WIDTH; } - if (GUI.Button(iconRect, new GUIContent("↑", "up"))) + if (GUI.Button(iconRect, Styles.iconUp, Styles.invisibleButton)) { if (i > 0) listProp.MoveArrayElement(i, i - 1); } @@ -345,7 +354,7 @@ public class ChartEditorHelper { iconRect.x += BLOCK_WIDTH; } - if (GUI.Button(iconRect, new GUIContent("↓", "down"))) + if (GUI.Button(iconRect, Styles.iconDown, Styles.invisibleButton)) { if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); } @@ -354,7 +363,7 @@ public class ChartEditorHelper { iconRect.x += BLOCK_WIDTH; } - if (GUI.Button(iconRect, new GUIContent("-", "delete"))) + if (GUI.Button(iconRect, Styles.iconRemove, Styles.invisibleButton)) { if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i); } @@ -385,7 +394,7 @@ public class ChartEditorHelper { EditorGUILayout.BeginHorizontal(); listSize = EditorGUILayout.IntField("Size", listSize); - if (GUILayout.Button(new GUIContent("+", "add"), GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) + if (GUILayout.Button(Styles.iconAdd, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) { listProp.arraySize++; } @@ -428,15 +437,15 @@ public class ChartEditorHelper { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(element, true); - if (GUILayout.Button(new GUIContent("↑", "up"), GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) + if (GUILayout.Button(Styles.iconUp, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) { if (i > 0) listProp.MoveArrayElement(i, i - 1); } - if (GUILayout.Button(new GUIContent("↓", "down"), GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) + if (GUILayout.Button(Styles.iconDown, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) { if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); } - if (GUILayout.Button(new GUIContent("-", "delete"), GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) + if (GUILayout.Button(Styles.iconRemove, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) { if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i); } diff --git a/Examples/Runtime/Example12_CustomDrawing.cs b/Examples/Runtime/Example12_CustomDrawing.cs index a99800a9..0d56b17f 100644 --- a/Examples/Runtime/Example12_CustomDrawing.cs +++ b/Examples/Runtime/Example12_CustomDrawing.cs @@ -30,8 +30,8 @@ namespace XCharts.Examples var pos = dataPoints[3]; var zeroPos = new Vector3(chart.grid.runtimeX, chart.grid.runtimeY); var startPos = new Vector3(pos.x, zeroPos.y); - var endPos = new Vector3(pos.x, zeroPos.y + chart.grid.runtimeWidth); - UGL.DrawLine(vh, startPos, endPos, 1, Color.blue); + var endPos = new Vector3(pos.x, zeroPos.y + chart.grid.runtimeHeight); + UGL.DrawLine(vh, startPos, endPos, chart.theme.serie.lineWidth, Color.blue); UGL.DrawCricle(vh, pos, 5, Color.blue); } }; diff --git a/README.md b/README.md index bce25b1d..826b2980 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,16 @@ [![downloads per month](http://img.shields.io/npm/dm/unity-ugui-xcharts.svg)](https://www.npmjs.org/package/unity-ugui-xcharts) ![qq](https://img.shields.io/badge/QQ群-202030963-green) ---- +## XCharts 2.0 -__XCharts 2.0 is comming soon!__ - -* Framework reconstruction, layered rendering, support more data -* Support TextMeshPro -* Support multi-chart, multi-component mode -* A friendlier editing interface -* More … - ---- +* Framework reconstruction, layered rendering, optimized scalability, support more data. +* Support for TextMeshPro. +* Support for multi-component patterns. +* Support for any combination of most charts. +* Support theme customization, import and export, and more theme configuration parameters. +* Support global adjustment of configuration parameters. +* Better editing interface. +* Other details optimized. A powerful, easy-to-use, configurable charting and data visualization library for Unity. Supporting line, bar, pie, radar, scatter, heatmap, gauge, ring, polar, liquid and other common chart. @@ -127,7 +126,7 @@ The following is the relationship structure of LineChart: * Download the source code or `unitypackage` to import into your project. If `Unity` version are `2018.3` or above, it is recommended to import packages through `Package Manager`: 1. Open the `manifest.json` file under `Packages` directory and add under `dependencies`: ``` json - "com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#package", + "com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#upm", ``` 2. Going back to `Unity`, it may take 3 to 5 minutes to download. 3. If you want to delete `XCharts`, just delete the content added in step 1.