mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 22:10:11 +00:00
增加HeatmapChart热力图
This commit is contained in:
@@ -16,6 +16,7 @@ namespace XCharts
|
||||
protected SerializedProperty m_MultipleYAxis;
|
||||
protected SerializedProperty m_YAxises;
|
||||
protected SerializedProperty m_DataZoom;
|
||||
protected SerializedProperty m_VisualMap;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
@@ -25,12 +26,14 @@ namespace XCharts
|
||||
m_XAxises = serializedObject.FindProperty("m_XAxises");
|
||||
m_YAxises = serializedObject.FindProperty("m_YAxises");
|
||||
m_DataZoom = serializedObject.FindProperty("m_DataZoom");
|
||||
m_VisualMap = serializedObject.FindProperty("m_VisualMap");
|
||||
}
|
||||
|
||||
protected override void OnStartInspectorGUI()
|
||||
{
|
||||
base.OnStartInspectorGUI();
|
||||
EditorGUILayout.PropertyField(m_DataZoom);
|
||||
EditorGUILayout.PropertyField(m_VisualMap);
|
||||
EditorGUILayout.PropertyField(m_Grid);
|
||||
for (int i = 0; i < m_XAxises.arraySize; i++)
|
||||
{
|
||||
|
||||
23
Scripts/Editor/HeatmapChartEditor.cs
Normal file
23
Scripts/Editor/HeatmapChartEditor.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI HeatmapChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(HeatmapChart), false)]
|
||||
public class HeatmapChartEditor : CoordinateChartEditor
|
||||
{
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (HeatmapChart)target;
|
||||
}
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
{
|
||||
base.OnEndInspectorGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/HeatmapChartEditor.cs.meta
Normal file
11
Scripts/Editor/HeatmapChartEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1144057dfc00f4572913a63ba5291dd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Scripts/Editor/PropertyDrawers/EmphasisStyleDrawer.cs
Normal file
48
Scripts/Editor/PropertyDrawers/EmphasisStyleDrawer.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Emphasis), true)]
|
||||
public class EmphasisDrawer : PropertyDrawer
|
||||
{
|
||||
private Dictionary<string, bool> m_EmphasisToggle = new Dictionary<string, bool>();
|
||||
|
||||
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_Label = prop.FindPropertyRelative("m_Label");
|
||||
SerializedProperty m_ItemStyle = prop.FindPropertyRelative("m_ItemStyle");
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_EmphasisToggle, prop, "Emphasis", show, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (ChartEditorHelper.IsToggle(m_EmphasisToggle, prop))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Label);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (ChartEditorHelper.IsToggle(m_EmphasisToggle, prop))
|
||||
{
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/PropertyDrawers/EmphasisStyleDrawer.cs.meta
Normal file
11
Scripts/Editor/PropertyDrawers/EmphasisStyleDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7de9b5e4c5d474fdd88ebb89f0924305
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Scripts/Editor/PropertyDrawers/ItemStyleDrawer.cs
Normal file
55
Scripts/Editor/PropertyDrawers/ItemStyleDrawer.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(ItemStyle), true)]
|
||||
public class ItemStyleDrawer : PropertyDrawer
|
||||
{
|
||||
private Dictionary<string, bool> m_ItemStyleToggle = new Dictionary<string, bool>();
|
||||
|
||||
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_Color = prop.FindPropertyRelative("m_Color");
|
||||
SerializedProperty m_BorderType = prop.FindPropertyRelative("m_BorderType");
|
||||
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
|
||||
SerializedProperty m_BorderColor = prop.FindPropertyRelative("m_BorderColor");
|
||||
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_ItemStyleToggle, prop, "Item Style", show, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (ChartEditorHelper.IsToggle(m_ItemStyleToggle, prop))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Color);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BorderType);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BorderWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BorderColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Opacity);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (ChartEditorHelper.IsToggle(m_ItemStyleToggle, prop))
|
||||
{
|
||||
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/PropertyDrawers/ItemStyleDrawer.cs.meta
Normal file
11
Scripts/Editor/PropertyDrawers/ItemStyleDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f40830a3b05574467ad0d8873c6c8790
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -27,6 +27,7 @@ namespace XCharts
|
||||
SerializedProperty m_MaxCache = prop.FindPropertyRelative("m_MaxCache");
|
||||
|
||||
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||
SerializedProperty m_ItemStyle = prop.FindPropertyRelative("m_ItemStyle");
|
||||
SerializedProperty m_LineArrow = prop.FindPropertyRelative("m_LineArrow");
|
||||
SerializedProperty m_LineType = prop.FindPropertyRelative("m_LineType");
|
||||
SerializedProperty m_SampleDist = prop.FindPropertyRelative("m_SampleDist");
|
||||
@@ -42,7 +43,7 @@ namespace XCharts
|
||||
SerializedProperty m_Center = prop.FindPropertyRelative("m_Center");
|
||||
SerializedProperty m_Radius = prop.FindPropertyRelative("m_Radius");
|
||||
SerializedProperty m_Label = prop.FindPropertyRelative("m_Label");
|
||||
SerializedProperty m_HighlightLabel = prop.FindPropertyRelative("m_HighlightLabel");
|
||||
SerializedProperty m_Emphasis = prop.FindPropertyRelative("m_Emphasis");
|
||||
SerializedProperty m_Animation = prop.FindPropertyRelative("m_Animation");
|
||||
SerializedProperty m_DataDimension = prop.FindPropertyRelative("m_ShowDataDimension");
|
||||
SerializedProperty m_ShowDataName = prop.FindPropertyRelative("m_ShowDataName");
|
||||
@@ -125,31 +126,8 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, m_Space);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.LabelField(drawRect, "Center");
|
||||
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
||||
var tempWidth = (pos.width - startX + 35) / 2;
|
||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
||||
var centerYRect = new Rect(centerXRect.x + tempWidth - 20, drawRect.y, tempWidth, drawRect.height);
|
||||
while (m_Center.arraySize < 2)
|
||||
{
|
||||
m_Center.InsertArrayElementAtIndex(m_Center.arraySize);
|
||||
}
|
||||
EditorGUI.PropertyField(centerXRect, m_Center.GetArrayElementAtIndex(0), GUIContent.none);
|
||||
EditorGUI.PropertyField(centerYRect, m_Center.GetArrayElementAtIndex(1), GUIContent.none);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
||||
centerYRect = new Rect(centerXRect.x + tempWidth - 20, drawRect.y, tempWidth, drawRect.height);
|
||||
EditorGUI.LabelField(drawRect, "Radius");
|
||||
while (m_Radius.arraySize < 2)
|
||||
{
|
||||
m_Radius.InsertArrayElementAtIndex(m_Radius.arraySize);
|
||||
}
|
||||
EditorGUI.PropertyField(centerXRect, m_Radius.GetArrayElementAtIndex(0), GUIContent.none);
|
||||
EditorGUI.PropertyField(centerYRect, m_Radius.GetArrayElementAtIndex(1), GUIContent.none);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ClickOffset);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
ChartEditorHelper.MakeTwoField(ref drawRect,pos.width,m_Center,"Center");
|
||||
ChartEditorHelper.MakeTwoField(ref drawRect,pos.width,m_Center,"Radius");
|
||||
}
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
@@ -159,12 +137,14 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, m_LineArrow);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineArrow);
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||
EditorGUI.PropertyField(drawRect, m_AreaStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
|
||||
EditorGUI.PropertyField(drawRect, m_Label, new GUIContent("Normal Label"));
|
||||
EditorGUI.PropertyField(drawRect, m_Label);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||
EditorGUI.PropertyField(drawRect, m_HighlightLabel, new GUIContent("Highlight Label"));
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_HighlightLabel);
|
||||
EditorGUI.PropertyField(drawRect, m_Emphasis);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
||||
EditorGUI.PropertyField(drawRect, m_Animation);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Animation);
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
@@ -344,9 +324,10 @@ namespace XCharts
|
||||
{
|
||||
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_HighlightLabel"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||
SerializedProperty type = prop.FindPropertyRelative("m_Type");
|
||||
var serieType = (SerieType)type.enumValueIndex;
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace XCharts
|
||||
SerializedProperty m_LineSmoothness = prop.FindPropertyRelative("m_LineSmoothness");
|
||||
SerializedProperty m_LineSegmentDistance = prop.FindPropertyRelative("m_LineSegmentDistance");
|
||||
SerializedProperty m_CicleSmoothness = prop.FindPropertyRelative("m_CicleSmoothness");
|
||||
SerializedProperty m_VisualMapTriangeLen = prop.FindPropertyRelative("m_VisualMapTriangeLen");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SettingsModuleToggle, "Settings");
|
||||
EditorGUI.LabelField(drawRect, "Settings", EditorStyles.boldLabel);
|
||||
@@ -32,6 +33,8 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_CicleSmoothness);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_VisualMapTriangeLen);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +44,7 @@ namespace XCharts
|
||||
int num = 1;
|
||||
if (m_SettingsModuleToggle)
|
||||
{
|
||||
num = 5;
|
||||
num = 6;
|
||||
}
|
||||
return num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace XCharts
|
||||
SerializedProperty m_DataZoomLineColor = prop.FindPropertyRelative("m_DataZoomLineColor");
|
||||
SerializedProperty m_DataZoomSelectedColor = prop.FindPropertyRelative("m_DataZoomSelectedColor");
|
||||
SerializedProperty m_DataZoomTextColor = prop.FindPropertyRelative("m_DataZoomTextColor");
|
||||
SerializedProperty m_VisualMapBackgroundColor = prop.FindPropertyRelative("m_VisualMapBackgroundColor");
|
||||
SerializedProperty m_VisualMapBorderColor = prop.FindPropertyRelative("m_VisualMapBorderColor");
|
||||
SerializedProperty m_ColorPalette = prop.FindPropertyRelative("m_ColorPalette");
|
||||
|
||||
SerializedProperty m_CustomFont = prop.FindPropertyRelative("m_CustomFont");
|
||||
@@ -54,6 +56,8 @@ namespace XCharts
|
||||
SerializedProperty m_CustomDataZoomLineColor = prop.FindPropertyRelative("m_CustomDataZoomLineColor");
|
||||
SerializedProperty m_CustomDataZoomSelectedColor = prop.FindPropertyRelative("m_CustomDataZoomSelectedColor");
|
||||
SerializedProperty m_CustomDataZoomTextColor = prop.FindPropertyRelative("m_CustomDataZoomTextColor");
|
||||
SerializedProperty m_CustomVisualMapBackgroundColor = prop.FindPropertyRelative("m_CustomVisualMapBackgroundColor");
|
||||
SerializedProperty m_CustomVisualMapBorderColor = prop.FindPropertyRelative("m_CustomVisualMapBorderColor");
|
||||
SerializedProperty m_CustomColorPalette = prop.FindPropertyRelative("m_CustomColorPalette");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_ThemeModuleToggle, "Theme");
|
||||
@@ -83,6 +87,8 @@ namespace XCharts
|
||||
m_CustomDataZoomLineColor.colorValue = Color.clear;
|
||||
m_CustomDataZoomSelectedColor.colorValue = Color.clear;
|
||||
m_CustomDataZoomTextColor.colorValue = Color.clear;
|
||||
m_CustomVisualMapBackgroundColor.colorValue = Color.clear;
|
||||
m_CustomVisualMapBorderColor.colorValue = Color.clear;
|
||||
for (int i = 0; i < m_CustomColorPalette.arraySize; i++)
|
||||
{
|
||||
m_CustomColorPalette.GetArrayElementAtIndex(i).colorValue = Color.clear;
|
||||
@@ -112,6 +118,8 @@ namespace XCharts
|
||||
m_DataZoomLineColor.colorValue = defaultThemeInfo.dataZoomLineColor;
|
||||
m_DataZoomSelectedColor.colorValue = defaultThemeInfo.dataZoomSelectedColor;
|
||||
m_DataZoomTextColor.colorValue = defaultThemeInfo.dataZoomTextColor;
|
||||
m_VisualMapBackgroundColor.colorValue = defaultThemeInfo.visualMapBackgroundColor;
|
||||
m_VisualMapBorderColor.colorValue = defaultThemeInfo.visualMapBorderColor;
|
||||
for (int i = 0; i < m_ColorPalette.arraySize; i++)
|
||||
{
|
||||
m_ColorPalette.GetArrayElementAtIndex(i).colorValue = defaultThemeInfo.GetColor(i);
|
||||
@@ -276,6 +284,24 @@ namespace XCharts
|
||||
}
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
color = m_CustomVisualMapBackgroundColor.colorValue != Color.clear ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor;
|
||||
EditorGUI.PropertyField(drawRect, color, new GUIContent("VisualMap Background Color"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_CustomVisualMapBackgroundColor.colorValue = color.colorValue;
|
||||
}
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
color = m_CustomVisualMapBorderColor.colorValue != Color.clear ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor;
|
||||
EditorGUI.PropertyField(drawRect, color, new GUIContent("VisualMap Border Color"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_CustomVisualMapBorderColor.colorValue = color.colorValue;
|
||||
}
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
m_ColorPaletteFoldout = EditorGUI.Foldout(drawRect, m_ColorPaletteFoldout, "ColorPalette");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_ColorPaletteFoldout)
|
||||
@@ -315,7 +341,7 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
float height = 0;
|
||||
int propertyCount = 18;
|
||||
int propertyCount = 20;
|
||||
if (m_ColorPaletteFoldout)
|
||||
{
|
||||
SerializedProperty m_ColorPalette = prop.FindPropertyRelative("m_ColorPalette");
|
||||
|
||||
138
Scripts/Editor/PropertyDrawers/VisualMapDrawer.cs
Normal file
138
Scripts/Editor/PropertyDrawers/VisualMapDrawer.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(VisualMap), true)]
|
||||
public class VisualMapDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_VisualMapModuleToggle = false;
|
||||
private bool m_InRangeFoldout;
|
||||
private bool m_OutOfRangeFoldout;
|
||||
private int m_InRangeSize;
|
||||
private int m_OutOfRangeSize;
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
SerializedProperty m_Enable = prop.FindPropertyRelative("m_Enable");
|
||||
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
||||
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
|
||||
SerializedProperty m_SelectedMode = prop.FindPropertyRelative("m_SelectedMode");
|
||||
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
||||
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
||||
SerializedProperty m_Range = prop.FindPropertyRelative("m_Range");
|
||||
SerializedProperty m_Text = prop.FindPropertyRelative("m_Text");
|
||||
SerializedProperty m_TextGap = prop.FindPropertyRelative("m_TextGap");
|
||||
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||
SerializedProperty m_Calculable = prop.FindPropertyRelative("m_Calculable");
|
||||
SerializedProperty m_ItemWidth = prop.FindPropertyRelative("m_ItemWidth");
|
||||
SerializedProperty m_ItemHeight = prop.FindPropertyRelative("m_ItemHeight");
|
||||
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
|
||||
SerializedProperty m_Dimension = prop.FindPropertyRelative("m_Dimension");
|
||||
SerializedProperty m_HoverLink = prop.FindPropertyRelative("m_HoverLink");
|
||||
SerializedProperty m_Orient = prop.FindPropertyRelative("m_Orient");
|
||||
SerializedProperty m_Location = prop.FindPropertyRelative("m_Location");
|
||||
SerializedProperty m_InRange = prop.FindPropertyRelative("m_InRange");
|
||||
SerializedProperty m_OutOfRange = prop.FindPropertyRelative("m_OutOfRange");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_VisualMapModuleToggle, "Visual Map", m_Enable);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_VisualMapModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Type);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_Min);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Max);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Dimension);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_HoverLink);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
m_InRangeFoldout = EditorGUI.Foldout(drawRect, m_InRangeFoldout, "InRange");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_InRangeFoldout)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_InRangeSize, m_InRange);
|
||||
}
|
||||
|
||||
// drawRect.width = pos.width;
|
||||
// m_OutOfRangeFoldout = EditorGUI.Foldout(drawRect, m_OutOfRangeFoldout, "OutOfRange");
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// if (m_OutOfRangeFoldout)
|
||||
// {
|
||||
// ChartEditorHelper.MakeList(ref drawRect, ref m_OutOfRangeSize, m_OutOfRange);
|
||||
// }
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_Show);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_Show.boolValue)
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, m_SelectedMode);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Range, "Range");
|
||||
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Text, "Text");
|
||||
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Text, "TextGap");
|
||||
EditorGUI.PropertyField(drawRect, m_Calculable);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ItemWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ItemHeight);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BorderWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Orient);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Location);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Location);
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
int num = 1;
|
||||
if (m_VisualMapModuleToggle)
|
||||
{
|
||||
num += 8;
|
||||
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
if (m_InRangeFoldout)
|
||||
{
|
||||
SerializedProperty m_InRange = prop.FindPropertyRelative("m_InRange");
|
||||
int size = m_InRange.arraySize + 1;
|
||||
height += size * EditorGUIUtility.singleLineHeight + (size - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
// if (m_OutOfRangeFoldout)
|
||||
// {
|
||||
// SerializedProperty m_OutOfRange = prop.FindPropertyRelative("m_OutOfRange");
|
||||
// int size = m_OutOfRange.arraySize + 1;
|
||||
// height += size * EditorGUIUtility.singleLineHeight + (size - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
// height += EditorGUIUtility.standardVerticalSpacing;
|
||||
// }
|
||||
if (prop.FindPropertyRelative("m_Show").boolValue)
|
||||
{
|
||||
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Location"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/PropertyDrawers/VisualMapDrawer.cs.meta
Normal file
11
Scripts/Editor/PropertyDrawers/VisualMapDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fe31d791669a4014ac78fd7a2af9a6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -19,6 +19,29 @@ public class ChartEditorHelper
|
||||
drawRect = offset.Remove(drawRect);
|
||||
}
|
||||
|
||||
public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp, string name)
|
||||
{
|
||||
while (arrayProp.arraySize < 2)
|
||||
{
|
||||
arrayProp.InsertArrayElementAtIndex(arrayProp.arraySize);
|
||||
}
|
||||
MakeTwoField(ref drawRect, rectWidth, arrayProp.GetArrayElementAtIndex(0), arrayProp.GetArrayElementAtIndex(1), name);
|
||||
}
|
||||
|
||||
public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty prop1, SerializedProperty prop2, string name)
|
||||
{
|
||||
EditorGUI.LabelField(drawRect, name);
|
||||
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
||||
var diff = 14 + EditorGUI.indentLevel * 14;
|
||||
var offset = diff - 15;
|
||||
var tempWidth = (rectWidth - startX + diff) / 2;
|
||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
||||
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth, drawRect.height);
|
||||
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
|
||||
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
public static void MakeJsonData(ref Rect drawRect, ref bool showTextArea, ref string inputString,
|
||||
SerializedProperty prop, float currentWidth, float diff = 0)
|
||||
{
|
||||
@@ -91,7 +114,7 @@ public class ChartEditorHelper
|
||||
{
|
||||
if (showProp.propertyType == SerializedPropertyType.Boolean)
|
||||
{
|
||||
drawRect.width = 40;
|
||||
drawRect.width = 60;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user