增加PolarChart极坐标图表

This commit is contained in:
monitor1394
2020-07-01 09:38:00 +08:00
parent 9e48c23225
commit b6139514f5
31 changed files with 59285 additions and 111 deletions

View File

@@ -0,0 +1,40 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI PolarChart.
/// </summary>
[CustomEditor(typeof(PolarChart), false)]
public class PolarChartEditor : BaseChartEditor
{
protected SerializedProperty m_Polar;
protected SerializedProperty m_RadiusAxis;
protected SerializedProperty m_AngleAxis;
protected override void OnEnable()
{
base.OnEnable();
m_Target = (PolarChart)target;
m_Polar = serializedObject.FindProperty("m_Polar");
m_RadiusAxis = serializedObject.FindProperty("m_RadiusAxis");
m_AngleAxis = serializedObject.FindProperty("m_AngleAxis");
}
protected override void OnStartInspectorGUI()
{
base.OnStartInspectorGUI();
EditorGUILayout.PropertyField(m_Polar, true);
EditorGUILayout.PropertyField(m_RadiusAxis, true);
EditorGUILayout.PropertyField(m_AngleAxis, true);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 157ef5f1d75e04aa1814e0b188591912
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(AngleAxis), true)]
public class AngleAxisDrawer : AxisDrawer
{
protected override void DrawExtended(ref Rect drawRect, SerializedProperty prop)
{
SerializedProperty m_StartAngle = prop.FindPropertyRelative("m_StartAngle");
//SerializedProperty m_Clockwise = prop.FindPropertyRelative("m_Clockwise");
EditorGUI.PropertyField(drawRect, m_StartAngle);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
//EditorGUI.PropertyField(drawRect, m_Clockwise);
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
protected override string GetDisplayName(string displayName)
{
if (displayName.StartsWith("Element"))
{
displayName = displayName.Replace("Element", "Angle Axis");
}
return displayName;
}
protected override float GetExtendedHeight()
{
return 1 * EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 521ea44136ea74a2f82a4c0c46edfd32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -100,6 +100,7 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BoundaryGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
DrawExtended(ref drawRect, prop);
EditorGUI.PropertyField(drawRect, m_AxisLine);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLine);
@@ -133,6 +134,11 @@ namespace XCharts
}
}
protected virtual void DrawExtended(ref Rect drawRect, SerializedProperty prop)
{
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
int index = InitToggle(prop);
@@ -195,10 +201,16 @@ namespace XCharts
height += EditorGUI.GetPropertyHeight(m_AxisLabel);
height += EditorGUI.GetPropertyHeight(m_SplitArea);
height += EditorGUI.GetPropertyHeight(m_SplitLine);
height += GetExtendedHeight();
return height;
}
}
protected virtual float GetExtendedHeight()
{
return 0;
}
private int InitToggle(SerializedProperty prop)
{
int index = 0;

View File

@@ -0,0 +1,49 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Polar), true)]
public class PolarDrawer : PropertyDrawer
{
private bool m_PolarModuleToggle = false;
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Center = prop.FindPropertyRelative("m_Center");
SerializedProperty m_Radius = prop.FindPropertyRelative("m_Radius");
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_PolarModuleToggle, "Polar", show);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_PolarModuleToggle)
{
EditorGUI.indentLevel++;
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
EditorGUI.PropertyField(drawRect, m_Radius);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.indentLevel--;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
if (m_PolarModuleToggle)
return 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
else
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48ff9465776e54e749f9ff8c424bafe2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{
[CustomPropertyDrawer(typeof(RadiusAxis), true)]
public class RadiusAxisDrawer : AxisDrawer
{
protected override string GetDisplayName(string displayName)
{
if (displayName.StartsWith("Element"))
{
displayName = displayName.Replace("Element", "Radius Axis");
}
return displayName;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 433e6c679c39c4bf988a0447fd2e3775
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -127,5 +127,12 @@ namespace XCharts
{
AddChart<RingChart>("RingChart");
}
[MenuItem("XCharts/PolarChart", priority = 52)]
[MenuItem("GameObject/XCharts/PolarChart", priority = 52)]
public static void AddPolarChart()
{
AddChart<PolarChart>("PolarChart");
}
}
}