mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 15:00:08 +00:00
0.2版本,重构代码,增加Editor
This commit is contained in:
31
Scripts/Editor/BarChartEditor.cs
Normal file
31
Scripts/Editor/BarChartEditor.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI BarChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(BarChart), false)]
|
||||
public class BarChartEditor : CoordinateChartEditor
|
||||
{
|
||||
protected SerializedProperty m_Bar;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (BarChart)target;
|
||||
m_Bar = serializedObject.FindProperty("m_Bar");
|
||||
}
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
{
|
||||
base.OnEndInspectorGUI();
|
||||
if (m_Target == null && target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EditorGUILayout.PropertyField(m_Bar, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/BarChartEditor.cs.meta
Normal file
13
Scripts/Editor/BarChartEditor.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5acea6fd06c0e9c498c434f941e4cba9
|
||||
timeCreated: 1554219116
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
115
Scripts/Editor/BaseChartEditor.cs
Normal file
115
Scripts/Editor/BaseChartEditor.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI BaseChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(BaseChart), false)]
|
||||
public class BaseChartEditor : Editor
|
||||
{
|
||||
protected BaseChart m_Target;
|
||||
protected SerializedProperty m_Script;
|
||||
protected SerializedProperty m_Theme;
|
||||
protected SerializedProperty m_ThemeInfo;
|
||||
protected SerializedProperty m_Title;
|
||||
protected SerializedProperty m_Legend;
|
||||
protected SerializedProperty m_Tooltip;
|
||||
protected SerializedProperty m_Series;
|
||||
|
||||
protected SerializedProperty m_Large;
|
||||
protected SerializedProperty m_MinShowDataNumber;
|
||||
protected SerializedProperty m_MaxShowDataNumber;
|
||||
protected SerializedProperty m_MaxCacheDataNumber;
|
||||
|
||||
protected float m_DefaultLabelWidth;
|
||||
protected float m_DefaultFieldWidth;
|
||||
|
||||
private int m_SeriesSize;
|
||||
|
||||
|
||||
private bool m_ThemeModuleToggle = false;
|
||||
private bool m_BaseModuleToggle = false;
|
||||
|
||||
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_Target = (BaseChart)target;
|
||||
m_Script = serializedObject.FindProperty("m_Script");
|
||||
m_Theme = serializedObject.FindProperty("m_Theme");
|
||||
m_ThemeInfo = serializedObject.FindProperty("m_ThemeInfo");
|
||||
m_Title = serializedObject.FindProperty("m_Title");
|
||||
m_Legend = serializedObject.FindProperty("m_Legend");
|
||||
m_Tooltip = serializedObject.FindProperty("m_Tooltip");
|
||||
m_Series = serializedObject.FindProperty("m_Series");
|
||||
|
||||
m_Large = serializedObject.FindProperty("m_Large");
|
||||
m_MinShowDataNumber = serializedObject.FindProperty("m_MinShowDataNumber");
|
||||
m_MaxShowDataNumber = serializedObject.FindProperty("m_MaxShowDataNumber");
|
||||
m_MaxCacheDataNumber = serializedObject.FindProperty("m_MaxCacheDataNumber");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (m_Target == null && target == null)
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
return;
|
||||
}
|
||||
serializedObject.Update();
|
||||
m_DefaultLabelWidth = EditorGUIUtility.labelWidth;
|
||||
m_DefaultFieldWidth = EditorGUIUtility.fieldWidth;
|
||||
|
||||
OnStartInspectorGUI();
|
||||
OnMiddleInspectorGUI();
|
||||
OnEndInspectorGUI();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
protected virtual void OnStartInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_Script);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUIUtility.fieldWidth = EditorGUIUtility.labelWidth -5;
|
||||
m_ThemeModuleToggle = EditorGUILayout.Foldout(m_ThemeModuleToggle, "Theme", ChartEditorHelper.foldoutStyle);
|
||||
EditorGUILayout.PropertyField(m_Theme, GUIContent.none);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUIUtility.labelWidth = m_DefaultLabelWidth;
|
||||
EditorGUIUtility.fieldWidth = m_DefaultFieldWidth;
|
||||
if (m_ThemeModuleToggle)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_ThemeInfo, true);
|
||||
}
|
||||
EditorGUILayout.PropertyField(m_Title, true);
|
||||
EditorGUILayout.PropertyField(m_Legend, true);
|
||||
EditorGUILayout.PropertyField(m_Tooltip, true);
|
||||
}
|
||||
|
||||
protected virtual void OnMiddleInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_Series,true);
|
||||
m_BaseModuleToggle = EditorGUILayout.Foldout(m_BaseModuleToggle, "Base", ChartEditorHelper.foldoutStyle);
|
||||
if (m_BaseModuleToggle)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(m_Large, true);
|
||||
EditorGUILayout.PropertyField(m_MinShowDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_MaxShowDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_MaxCacheDataNumber, true);
|
||||
if (m_MinShowDataNumber.intValue < 0) m_MinShowDataNumber.intValue = 0;
|
||||
if (m_MaxShowDataNumber.intValue < 0) m_MaxShowDataNumber.intValue = 0;
|
||||
if (m_MaxCacheDataNumber.intValue < 0) m_MaxCacheDataNumber.intValue = 0;
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnEndInspectorGUI()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/BaseChartEditor.cs.meta
Normal file
13
Scripts/Editor/BaseChartEditor.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7f1cff1e5bae244a872040086b1cfa8
|
||||
timeCreated: 1554217495
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Scripts/Editor/CoordinateChartEditor.cs
Normal file
33
Scripts/Editor/CoordinateChartEditor.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI BarChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(CoordinateChart), false)]
|
||||
public class CoordinateChartEditor : BaseChartEditor
|
||||
{
|
||||
protected SerializedProperty m_Coordinate;
|
||||
protected SerializedProperty m_XAxis;
|
||||
protected SerializedProperty m_YAxis;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (CoordinateChart)target;
|
||||
m_Coordinate = serializedObject.FindProperty("m_Coordinate");
|
||||
m_XAxis = serializedObject.FindProperty("m_XAxis");
|
||||
m_YAxis = serializedObject.FindProperty("m_YAxis");
|
||||
}
|
||||
|
||||
protected override void OnStartInspectorGUI()
|
||||
{
|
||||
base.OnStartInspectorGUI();
|
||||
EditorGUILayout.PropertyField(m_Coordinate);
|
||||
EditorGUILayout.PropertyField(m_XAxis);
|
||||
EditorGUILayout.PropertyField(m_YAxis);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/CoordinateChartEditor.cs.meta
Normal file
13
Scripts/Editor/CoordinateChartEditor.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1dd7acd8b13f3f14e9891af4e8dd0b0b
|
||||
timeCreated: 1554475249
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Scripts/Editor/LineChartEditor.cs
Normal file
27
Scripts/Editor/LineChartEditor.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI LineChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(LineChart), false)]
|
||||
public class LineChartEditor : CoordinateChartEditor
|
||||
{
|
||||
protected SerializedProperty m_Line;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (LineChart)target;
|
||||
m_Line = serializedObject.FindProperty("m_Line");
|
||||
}
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
{
|
||||
base.OnEndInspectorGUI();
|
||||
EditorGUILayout.PropertyField(m_Line, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/LineChartEditor.cs.meta
Normal file
13
Scripts/Editor/LineChartEditor.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bd1a238bc5b407408b8f902aa3db9fd
|
||||
timeCreated: 1554539035
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Scripts/Editor/PieChartEditor.cs
Normal file
27
Scripts/Editor/PieChartEditor.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI PieChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(PieChart), false)]
|
||||
public class PieChartEditor : BaseChartEditor
|
||||
{
|
||||
protected SerializedProperty m_Pie;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (PieChart)target;
|
||||
m_Pie = serializedObject.FindProperty("m_Pie");
|
||||
}
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
{
|
||||
base.OnEndInspectorGUI();
|
||||
EditorGUILayout.PropertyField(m_Pie, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PieChartEditor.cs.meta
Normal file
13
Scripts/Editor/PieChartEditor.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28de30021bed0f945af09633584fcb44
|
||||
timeCreated: 1554768152
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Scripts/Editor/PropertyDrawers.meta
Normal file
10
Scripts/Editor/PropertyDrawers.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ad1e8940e4805b49a18ea7a2cbd4bce
|
||||
folderAsset: yes
|
||||
timeCreated: 1554304641
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
139
Scripts/Editor/PropertyDrawers/AxisDrawer.cs
Normal file
139
Scripts/Editor/PropertyDrawers/AxisDrawer.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Axis), true)]
|
||||
public class AxisDrawer : PropertyDrawer
|
||||
{
|
||||
private ReorderableList m_DataList;
|
||||
private bool m_DataFoldout = false;
|
||||
private int m_DataSize = 0;
|
||||
private bool m_ShowJsonDataArea = false;
|
||||
private string m_JsonDataAreaText;
|
||||
private bool m_AxisModuleToggle = false;
|
||||
|
||||
private void InitReorderableList(SerializedProperty prop)
|
||||
{
|
||||
if (m_DataList == null)
|
||||
{
|
||||
SerializedProperty data = prop.FindPropertyRelative("m_Data");
|
||||
m_DataList = new ReorderableList(data.serializedObject, data, false, false, true, true);
|
||||
m_DataList.elementHeight = EditorGUIUtility.singleLineHeight;
|
||||
m_DataList.drawHeaderCallback += delegate (Rect rect)
|
||||
{
|
||||
EditorGUI.LabelField(rect, data.displayName);
|
||||
};
|
||||
|
||||
m_DataList.drawElementCallback = delegate (Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
EditorGUI.PropertyField(rect, data.GetArrayElementAtIndex(index), true);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
|
||||
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
||||
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||
SerializedProperty m_TextRotation = prop.FindPropertyRelative("m_TextRotation");
|
||||
SerializedProperty m_ShowSplitLine = prop.FindPropertyRelative("m_ShowSplitLine");
|
||||
SerializedProperty m_SplitLineType = prop.FindPropertyRelative("m_SplitLineType");
|
||||
SerializedProperty m_BoundaryGap = prop.FindPropertyRelative("m_BoundaryGap");
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisModuleToggle, prop.displayName, m_Show);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_AxisModuleToggle)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUI.PropertyField(drawRect, m_Type);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_TextRotation);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_ShowSplitLine.boolValue)
|
||||
{
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
EditorGUI.PropertyField(drawRect, m_ShowSplitLine);
|
||||
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 35;
|
||||
drawRect.width = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 55;
|
||||
EditorGUI.PropertyField(drawRect, m_SplitLineType, GUIContent.none);
|
||||
drawRect.x = pos.x;
|
||||
drawRect.width = pos.width;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, m_ShowSplitLine);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, m_BoundaryGap);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_AxisTick);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisTick);
|
||||
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
|
||||
if (type == Axis.AxisType.Category)
|
||||
{
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Data");
|
||||
ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop);
|
||||
drawRect.width = pos.width;
|
||||
if (m_DataFoldout)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Data);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (!m_AxisModuleToggle)
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
||||
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
||||
float height = 0;
|
||||
height += 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
|
||||
if (type == Axis.AxisType.Category)
|
||||
{
|
||||
if (m_DataFoldout)
|
||||
{
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
int num = m_Data.arraySize + 2;
|
||||
if (num > 50) num = 13;
|
||||
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (m_ShowJsonDataArea)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
height += EditorGUI.GetPropertyHeight(m_AxisTick);
|
||||
return height;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/AxisDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/AxisDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0544f1db7f17644bb3cbe7c85da84d5
|
||||
timeCreated: 1554507809
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Scripts/Editor/PropertyDrawers/AxisTickDrawer.cs
Normal file
46
Scripts/Editor/PropertyDrawers/AxisTickDrawer.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Axis.AxisTick), true)]
|
||||
public class AxisTickDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_AxisTickToggle = 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_AlignWithLabel = prop.FindPropertyRelative("m_AlignWithLabel");
|
||||
SerializedProperty m_Inside = prop.FindPropertyRelative("m_Inside");
|
||||
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisTickToggle, "Axis Tick", show, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_AxisTickToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_AlignWithLabel);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Inside);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Length);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (m_AxisTickToggle)
|
||||
{
|
||||
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/AxisTickDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/AxisTickDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c7d45bc59dedc140b08f6e9d26ccd9d
|
||||
timeCreated: 1555890921
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Scripts/Editor/PropertyDrawers/BarDrawer.cs
Normal file
48
Scripts/Editor/PropertyDrawers/BarDrawer.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(BarChart.Bar), true)]
|
||||
public class BarDrawer : PropertyDrawer
|
||||
{
|
||||
SerializedProperty m_BarWidth;
|
||||
SerializedProperty m_Space;
|
||||
bool m_BarModuleToggle = true;
|
||||
|
||||
private void InitProperty(SerializedProperty prop)
|
||||
{
|
||||
m_BarWidth = prop.FindPropertyRelative("m_BarWidth");
|
||||
m_Space = prop.FindPropertyRelative("m_Space");
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
InitProperty(prop);
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_BarModuleToggle, "Bar");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
if (m_BarModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_BarWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Space);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_BarModuleToggle)
|
||||
return 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||
else
|
||||
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/BarDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/BarDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a443d39bebe073645a240a745feb9fc5
|
||||
timeCreated: 1554768582
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Scripts/Editor/PropertyDrawers/CoordinateDrawer.cs
Normal file
54
Scripts/Editor/PropertyDrawers/CoordinateDrawer.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Coordinate), true)]
|
||||
public class CoordinateDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_CoordinateModuleToggle = false;
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
SerializedProperty m_Left = prop.FindPropertyRelative("m_Left");
|
||||
SerializedProperty m_Right = prop.FindPropertyRelative("m_Right");
|
||||
SerializedProperty m_Top = prop.FindPropertyRelative("m_Top");
|
||||
SerializedProperty m_Bottom = prop.FindPropertyRelative("m_Bottom");
|
||||
SerializedProperty m_Tickness = prop.FindPropertyRelative("m_Tickness");
|
||||
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_CoordinateModuleToggle, "Coordinate");
|
||||
EditorGUI.LabelField(drawRect, "Coordinate",EditorStyles.boldLabel);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_CoordinateModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Tickness);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FontSize);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_CoordinateModuleToggle)
|
||||
return 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||
else
|
||||
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/CoordinateDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/CoordinateDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38e8e72dd7107db429232ccab308e27c
|
||||
timeCreated: 1554506762
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Scripts/Editor/PropertyDrawers/LegendDrawer.cs
Normal file
83
Scripts/Editor/PropertyDrawers/LegendDrawer.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Legend), true)]
|
||||
public class LegendDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_DataFoldout = false;
|
||||
private int m_DataSize = 0;
|
||||
private bool m_ShowJsonDataArea = false;
|
||||
private string m_JsonDataAreaText;
|
||||
private bool m_LegendModuleToggle = 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 orient = prop.FindPropertyRelative("m_Orient");
|
||||
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
||||
SerializedProperty itemWidth = prop.FindPropertyRelative("m_ItemWidth");
|
||||
SerializedProperty itemHeight = prop.FindPropertyRelative("m_ItemHeight");
|
||||
SerializedProperty itemGap = prop.FindPropertyRelative("m_ItemGap");
|
||||
SerializedProperty itemFontSize = prop.FindPropertyRelative("m_ItemFontSize");
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_LegendModuleToggle, "Legend", show);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_LegendModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, itemWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, itemHeight);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, itemGap);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, itemFontSize);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, orient);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, location);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(location);
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Data");
|
||||
ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop);
|
||||
drawRect.width = pos.width;
|
||||
if (m_DataFoldout)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Data);
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (m_LegendModuleToggle)
|
||||
{
|
||||
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(location);
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_DataFoldout)
|
||||
{
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
int num = m_Data.arraySize + 1;
|
||||
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
if (m_ShowJsonDataArea)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/LegendDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/LegendDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b96d10541649a23468168ba0bf1c0bc5
|
||||
timeCreated: 1554395454
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Scripts/Editor/PropertyDrawers/LineDrawer.cs
Normal file
93
Scripts/Editor/PropertyDrawers/LineDrawer.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Line), true)]
|
||||
public class LineDrawer : PropertyDrawer
|
||||
{
|
||||
SerializedProperty m_Tickness;
|
||||
SerializedProperty m_Point;
|
||||
SerializedProperty m_PointWidth;
|
||||
SerializedProperty m_Smooth;
|
||||
SerializedProperty m_SmoothStyle;
|
||||
SerializedProperty m_Area;
|
||||
|
||||
private bool m_LineModuleToggle = false;
|
||||
|
||||
private void InitProperty(SerializedProperty prop)
|
||||
{
|
||||
m_Tickness = prop.FindPropertyRelative("m_Tickness");
|
||||
m_Point = prop.FindPropertyRelative("m_Point");
|
||||
m_PointWidth = prop.FindPropertyRelative("m_PointWidth");
|
||||
m_Smooth = prop.FindPropertyRelative("m_Smooth");
|
||||
m_SmoothStyle = prop.FindPropertyRelative("m_SmoothStyle");
|
||||
m_Area = prop.FindPropertyRelative("m_Area");
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
InitProperty(prop);
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_LineModuleToggle, "Line");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_LineModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Tickness);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
EditorGUI.PropertyField(drawRect, m_Point);
|
||||
if (m_Point.boolValue)
|
||||
{
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 15;
|
||||
EditorGUI.LabelField(drawRect,"Width");
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 65;
|
||||
float tempWidth = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 70;
|
||||
if (tempWidth < 20) tempWidth = 20;
|
||||
drawRect.width = tempWidth;
|
||||
EditorGUI.PropertyField(drawRect, m_PointWidth, GUIContent.none);
|
||||
drawRect.x = pos.x;
|
||||
drawRect.width = pos.width;
|
||||
}
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
EditorGUI.PropertyField(drawRect, m_Smooth);
|
||||
if (m_Smooth.boolValue)
|
||||
{
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 15;
|
||||
EditorGUI.LabelField(drawRect, "Style");
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 65;
|
||||
float tempWidth = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 70;
|
||||
if (tempWidth < 20) tempWidth = 20;
|
||||
drawRect.width = tempWidth;
|
||||
EditorGUI.PropertyField(drawRect, m_SmoothStyle, GUIContent.none);
|
||||
drawRect.x = pos.x;
|
||||
drawRect.width = pos.width;
|
||||
}
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_Area);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_LineModuleToggle)
|
||||
{
|
||||
return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/LineDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/LineDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eeb8c12e86239b4e93a6c75d766cb15
|
||||
timeCreated: 1554720052
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Scripts/Editor/PropertyDrawers/LocationDrawer.cs
Normal file
87
Scripts/Editor/PropertyDrawers/LocationDrawer.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Location), true)]
|
||||
public class LocationDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
SerializedProperty align = prop.FindPropertyRelative("m_Align");
|
||||
SerializedProperty left = prop.FindPropertyRelative("m_Left");
|
||||
SerializedProperty right = prop.FindPropertyRelative("m_Right");
|
||||
SerializedProperty top = prop.FindPropertyRelative("m_Top");
|
||||
SerializedProperty bottom = prop.FindPropertyRelative("m_Bottom");
|
||||
EditorGUI.PropertyField(drawRect, align, new GUIContent("Location"));
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
++EditorGUI.indentLevel;
|
||||
switch ((Location.Align)align.enumValueIndex)
|
||||
{
|
||||
case Location.Align.TopCenter:
|
||||
EditorGUI.PropertyField(drawRect, top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.TopLeft:
|
||||
EditorGUI.PropertyField(drawRect, top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.TopRight:
|
||||
EditorGUI.PropertyField(drawRect, top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.BottomCenter:
|
||||
EditorGUI.PropertyField(drawRect, bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.BottomLeft:
|
||||
EditorGUI.PropertyField(drawRect, bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.BottomRight:
|
||||
EditorGUI.PropertyField(drawRect, bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.Center:
|
||||
break;
|
||||
case Location.Align.CenterLeft:
|
||||
EditorGUI.PropertyField(drawRect, left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.CenterRight:
|
||||
EditorGUI.PropertyField(drawRect, right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
SerializedProperty align = prop.FindPropertyRelative("m_Align");
|
||||
switch ((Location.Align)align.enumValueIndex)
|
||||
{
|
||||
case Location.Align.Center:
|
||||
return 1 * EditorGUIUtility.singleLineHeight + 0 * EditorGUIUtility.standardVerticalSpacing;
|
||||
case Location.Align.TopCenter:
|
||||
case Location.Align.BottomCenter:
|
||||
case Location.Align.CenterLeft:
|
||||
case Location.Align.CenterRight:
|
||||
return 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
default:
|
||||
return 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/LocationDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/LocationDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34092595791508d4b94b074a8788c388
|
||||
timeCreated: 1554307767
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Scripts/Editor/PropertyDrawers/PieDrawer.cs
Normal file
79
Scripts/Editor/PropertyDrawers/PieDrawer.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Pie), true)]
|
||||
public class PieInfoDrawer : PropertyDrawer
|
||||
{
|
||||
SerializedProperty m_Name;
|
||||
SerializedProperty m_InsideRadius;
|
||||
SerializedProperty m_OutsideRadius;
|
||||
SerializedProperty m_TooltipExtraRadius;
|
||||
SerializedProperty m_Rose;
|
||||
SerializedProperty m_Space;
|
||||
SerializedProperty m_Left;
|
||||
SerializedProperty m_Right;
|
||||
SerializedProperty m_Top;
|
||||
SerializedProperty m_Bottom;
|
||||
bool m_PieModuleToggle = true;
|
||||
|
||||
private void InitProperty(SerializedProperty prop)
|
||||
{
|
||||
m_Name = prop.FindPropertyRelative("m_Name");
|
||||
m_InsideRadius = prop.FindPropertyRelative("m_InsideRadius");
|
||||
m_OutsideRadius = prop.FindPropertyRelative("m_OutsideRadius");
|
||||
m_TooltipExtraRadius = prop.FindPropertyRelative("m_TooltipExtraRadius");
|
||||
m_Rose = prop.FindPropertyRelative("m_Rose");
|
||||
m_Space = prop.FindPropertyRelative("m_Space");
|
||||
m_Left = prop.FindPropertyRelative("m_Left");
|
||||
m_Right = prop.FindPropertyRelative("m_Right");
|
||||
m_Top = prop.FindPropertyRelative("m_Top");
|
||||
m_Bottom = prop.FindPropertyRelative("m_Bottom");
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
InitProperty(prop);
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_PieModuleToggle, "Pie");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_PieModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Name);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_InsideRadius);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_OutsideRadius);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_TooltipExtraRadius);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Rose);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Space);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_PieModuleToggle)
|
||||
return 11 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||
else
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/PieDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/PieDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 019eadbd43e952945925f357ae8ef74b
|
||||
timeCreated: 1554773154
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
158
Scripts/Editor/PropertyDrawers/RadarDrawer.cs
Normal file
158
Scripts/Editor/PropertyDrawers/RadarDrawer.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Radar), true)]
|
||||
public class RadarDrawer : PropertyDrawer
|
||||
{
|
||||
SerializedProperty m_Cricle;
|
||||
SerializedProperty m_Area;
|
||||
SerializedProperty m_Radius;
|
||||
SerializedProperty m_SplitNumber;
|
||||
SerializedProperty m_Left;
|
||||
SerializedProperty m_Right;
|
||||
SerializedProperty m_Top;
|
||||
SerializedProperty m_Bottom;
|
||||
SerializedProperty m_LineTickness;
|
||||
SerializedProperty m_LinePointSize;
|
||||
SerializedProperty m_LineColor;
|
||||
SerializedProperty m_BackgroundColorList;
|
||||
SerializedProperty m_Indicator;
|
||||
SerializedProperty m_IndicatorList;
|
||||
|
||||
private bool m_RadarModuleToggle = false;
|
||||
private bool m_IndicatorToggle = false;
|
||||
private bool m_IndicatorJsonAreaToggle = false;
|
||||
private string m_IndicatorJsonAreaText;
|
||||
private int m_IndicatorSize;
|
||||
private bool m_BackgroundColorToggle = false;
|
||||
private int m_BackgroundColorSize;
|
||||
|
||||
private void InitProperty(SerializedProperty prop)
|
||||
{
|
||||
m_Cricle = prop.FindPropertyRelative("m_Cricle");
|
||||
m_Area = prop.FindPropertyRelative("m_Area");
|
||||
m_Radius = prop.FindPropertyRelative("m_Radius");
|
||||
m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||
m_Left = prop.FindPropertyRelative("m_Left");
|
||||
m_Right = prop.FindPropertyRelative("m_Right");
|
||||
m_Top = prop.FindPropertyRelative("m_Top");
|
||||
m_Bottom = prop.FindPropertyRelative("m_Bottom");
|
||||
m_LineTickness = prop.FindPropertyRelative("m_LineTickness");
|
||||
m_LinePointSize = prop.FindPropertyRelative("m_LinePointSize");
|
||||
m_LineColor = prop.FindPropertyRelative("m_LineColor");
|
||||
m_BackgroundColorList = prop.FindPropertyRelative("m_BackgroundColorList");
|
||||
m_Indicator = prop.FindPropertyRelative("m_Indicator");
|
||||
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
InitProperty(prop);
|
||||
Rect drawRect = pos;
|
||||
float defaultLabelWidth = EditorGUIUtility.labelWidth;
|
||||
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, "Radar");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_RadarModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
|
||||
EditorGUIUtility.fieldWidth = 10;
|
||||
|
||||
EditorGUIUtility.labelWidth = 50;
|
||||
drawRect.width = 60;
|
||||
EditorGUI.PropertyField(drawRect, m_Cricle);
|
||||
|
||||
EditorGUIUtility.labelWidth = 45;
|
||||
drawRect.x += 60;
|
||||
EditorGUI.PropertyField(drawRect, m_Area);
|
||||
|
||||
EditorGUIUtility.labelWidth = 70;
|
||||
drawRect.x += 55;
|
||||
drawRect.width = 80;
|
||||
EditorGUI.PropertyField(drawRect, m_Indicator);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.x = pos.x;
|
||||
drawRect.width = pos.width;
|
||||
EditorGUIUtility.labelWidth = defaultLabelWidth;
|
||||
EditorGUIUtility.fieldWidth = defaultFieldWidth;
|
||||
EditorGUI.PropertyField(drawRect, m_Radius);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LineTickness);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LinePointSize);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LineColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
m_BackgroundColorToggle = EditorGUI.Foldout(drawRect, m_BackgroundColorToggle, "BackgroundColors");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.width = pos.width;
|
||||
if (m_BackgroundColorToggle)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_BackgroundColorSize, m_BackgroundColorList);
|
||||
}
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
m_IndicatorToggle = EditorGUI.Foldout(drawRect, m_IndicatorToggle, "Indicators");
|
||||
ChartEditorHelper.MakeJsonData(ref drawRect, ref m_IndicatorJsonAreaToggle, ref m_IndicatorJsonAreaText, prop);
|
||||
drawRect.width = pos.width;
|
||||
if (m_IndicatorToggle)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_IndicatorSize, m_IndicatorList);
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
int propNum = 1;
|
||||
if (m_RadarModuleToggle)
|
||||
{
|
||||
propNum += 12;
|
||||
|
||||
if (m_BackgroundColorToggle)
|
||||
{
|
||||
m_BackgroundColorList = prop.FindPropertyRelative("m_BackgroundColorList");
|
||||
propNum += 2;
|
||||
propNum += m_BackgroundColorList.arraySize;
|
||||
}
|
||||
if (m_IndicatorJsonAreaToggle) propNum += 4;
|
||||
|
||||
|
||||
float height = propNum * EditorGUIUtility.singleLineHeight + (propNum -1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
if (m_IndicatorToggle)
|
||||
{
|
||||
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
|
||||
height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
for(int i = 0; i < m_IndicatorSize; i++)
|
||||
{
|
||||
height += EditorGUI.GetPropertyHeight(m_IndicatorList.GetArrayElementAtIndex(i));
|
||||
}
|
||||
}
|
||||
return height;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/RadarDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/RadarDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09bf71ecf64f321468ac28af28bec878
|
||||
timeCreated: 1555563898
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
58
Scripts/Editor/PropertyDrawers/RadarIndicatorDrawer.cs
Normal file
58
Scripts/Editor/PropertyDrawers/RadarIndicatorDrawer.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Radar.Indicator), true)]
|
||||
public class RadarIndicatorDrawer : PropertyDrawer
|
||||
{
|
||||
SerializedProperty m_Name;
|
||||
SerializedProperty m_Max;
|
||||
|
||||
private bool m_RadarModuleToggle = false;
|
||||
|
||||
private void InitProperty(SerializedProperty prop)
|
||||
{
|
||||
m_Name = prop.FindPropertyRelative("m_Name");
|
||||
m_Max = prop.FindPropertyRelative("m_Max");
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
InitProperty(prop);
|
||||
Rect drawRect = pos;
|
||||
float defaultLabelWidth = EditorGUIUtility.labelWidth;
|
||||
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
m_RadarModuleToggle = EditorGUI.Foldout(drawRect, m_RadarModuleToggle, "Indicator");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_RadarModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_Name);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Max);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
int propNum = 1;
|
||||
if (m_RadarModuleToggle)
|
||||
{
|
||||
propNum += 2;
|
||||
return propNum * EditorGUIUtility.singleLineHeight + (propNum -1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/RadarIndicatorDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/RadarIndicatorDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fb5d2a98871919459956dc252632435
|
||||
timeCreated: 1556220585
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
77
Scripts/Editor/PropertyDrawers/SerieDrawer.cs
Normal file
77
Scripts/Editor/PropertyDrawers/SerieDrawer.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Serie), true)]
|
||||
public class SerieDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_DataFoldout = false;
|
||||
private int m_DataSize = 0;
|
||||
private bool m_ShowJsonDataArea = false;
|
||||
private string m_JsonDataAreaText;
|
||||
private bool m_SerieModuleToggle = 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 type = prop.FindPropertyRelative("m_Type");
|
||||
SerializedProperty name = prop.FindPropertyRelative("m_Name");
|
||||
SerializedProperty stack = prop.FindPropertyRelative("m_Stack");
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
|
||||
string moduleName = "Serie " + prop.displayName.Split(' ')[1];
|
||||
if (!string.IsNullOrEmpty(name.stringValue))
|
||||
moduleName += ":" + name.stringValue;
|
||||
m_SerieModuleToggle = EditorGUI.Foldout(drawRect, m_SerieModuleToggle, "Serie");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_SerieModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, show);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, name);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, stack);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Data");
|
||||
ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop);
|
||||
drawRect.width = pos.width;
|
||||
if (m_DataFoldout)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Data);
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (!m_SerieModuleToggle)
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_DataFoldout)
|
||||
{
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
int num = m_Data.arraySize + 1;
|
||||
if (num > 50) num = 13;
|
||||
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (m_ShowJsonDataArea)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/SerieDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/SerieDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c30d9496b99e39944a6987e390bed91f
|
||||
timeCreated: 1555200849
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Scripts/Editor/PropertyDrawers/SeriesDrawer.cs
Normal file
53
Scripts/Editor/PropertyDrawers/SeriesDrawer.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Series), true)]
|
||||
public class SeriesDrawer : PropertyDrawer
|
||||
{
|
||||
private int m_DataSize = 0;
|
||||
private bool m_ShowJsonDataArea = false;
|
||||
private string m_JsonDataAreaText;
|
||||
private bool m_SeriesModuleToggle = false;
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
SerializedProperty m_Series = prop.FindPropertyRelative("m_Series");
|
||||
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SeriesModuleToggle, "Series");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
//ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop);
|
||||
drawRect.width = pos.width;
|
||||
if (m_SeriesModuleToggle)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Series);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (m_SeriesModuleToggle)
|
||||
{
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Series");
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
for (int i = 0; i < m_Data.arraySize; i++)
|
||||
{
|
||||
height += EditorGUI.GetPropertyHeight(m_Data.GetArrayElementAtIndex(i));
|
||||
}
|
||||
}
|
||||
if (m_ShowJsonDataArea)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/SeriesDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/SeriesDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c2458b1901047547b1a59d097786816
|
||||
timeCreated: 1556016849
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
111
Scripts/Editor/PropertyDrawers/ThemeInfoDrawer.cs
Normal file
111
Scripts/Editor/PropertyDrawers/ThemeInfoDrawer.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(ThemeInfo), true)]
|
||||
public class ThemeInfoDrawer : PropertyDrawer
|
||||
{
|
||||
ReorderableList m_ColorPaletteList;
|
||||
bool m_ColorPaletteFoldout;
|
||||
|
||||
private void InitReorderableList(SerializedProperty prop)
|
||||
{
|
||||
if (m_ColorPaletteList == null)
|
||||
{
|
||||
SerializedProperty colorPalette = prop.FindPropertyRelative("m_ColorPalette");
|
||||
m_ColorPaletteList = new ReorderableList(colorPalette.serializedObject, colorPalette, false, false, true, true);
|
||||
m_ColorPaletteList.elementHeight = EditorGUIUtility.singleLineHeight;
|
||||
m_ColorPaletteList.drawHeaderCallback += delegate (Rect rect)
|
||||
{
|
||||
EditorGUI.LabelField(rect, colorPalette.displayName);
|
||||
};
|
||||
|
||||
m_ColorPaletteList.drawElementCallback = delegate (Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
EditorGUI.PropertyField(rect, colorPalette.GetArrayElementAtIndex(index), true);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
SerializedProperty m_Font = prop.FindPropertyRelative("m_Font");
|
||||
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
|
||||
SerializedProperty m_ContrastColor = prop.FindPropertyRelative("m_ContrastColor");
|
||||
SerializedProperty m_TextColor = prop.FindPropertyRelative("m_TextColor");
|
||||
SerializedProperty m_SubTextColor = prop.FindPropertyRelative("m_SubTextColor");
|
||||
SerializedProperty m_LegendTextColor = prop.FindPropertyRelative("m_LegendTextColor");
|
||||
SerializedProperty m_UnableColor = prop.FindPropertyRelative("m_UnableColor");
|
||||
SerializedProperty m_AxisLineColor = prop.FindPropertyRelative("m_AxisLineColor");
|
||||
SerializedProperty m_AxisSplitLineColor = prop.FindPropertyRelative("m_AxisSplitLineColor");
|
||||
SerializedProperty m_TooltipBackgroundColor = prop.FindPropertyRelative("m_TooltipBackgroundColor");
|
||||
SerializedProperty m_TooltipFlagAreaColor = prop.FindPropertyRelative("m_TooltipFlagAreaColor");
|
||||
SerializedProperty m_TooltipTextColor = prop.FindPropertyRelative("m_TooltipTextColor");
|
||||
SerializedProperty m_ColorPalette = prop.FindPropertyRelative("m_ColorPalette");
|
||||
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Font);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ContrastColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_TextColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_SubTextColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LegendTextColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_UnableColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_AxisLineColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_AxisSplitLineColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_TooltipBackgroundColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_TooltipFlagAreaColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_TooltipTextColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
m_ColorPaletteFoldout = EditorGUI.Foldout(drawRect, m_ColorPaletteFoldout, "ColorPalette");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_ColorPaletteFoldout)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
for (int i = 0; i < m_ColorPalette.arraySize; i++)
|
||||
{
|
||||
SerializedProperty element = m_ColorPalette.GetArrayElementAtIndex(i);
|
||||
EditorGUI.PropertyField(drawRect, element);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
int propertyCount = 12;
|
||||
if (m_ColorPaletteFoldout)
|
||||
{
|
||||
SerializedProperty m_ColorPalette = prop.FindPropertyRelative("m_ColorPalette");
|
||||
propertyCount += m_ColorPalette.arraySize + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyCount += 1;
|
||||
}
|
||||
height += propertyCount * EditorGUIUtility.singleLineHeight + (propertyCount - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/ThemeInfoDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/ThemeInfoDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcac1baa719179549b24d7056f7e0cb5
|
||||
timeCreated: 1554541305
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Scripts/Editor/PropertyDrawers/TitleDrawer.cs
Normal file
61
Scripts/Editor/PropertyDrawers/TitleDrawer.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Title), true)]
|
||||
public class TitleDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_TitleModuleToggle = 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 text = prop.FindPropertyRelative("m_Text");
|
||||
SerializedProperty m_TextFontSize = prop.FindPropertyRelative("m_TextFontSize");
|
||||
SerializedProperty subText = prop.FindPropertyRelative("m_SubText");
|
||||
SerializedProperty m_SubTextFontSize = prop.FindPropertyRelative("m_SubTextFontSize");
|
||||
SerializedProperty m_ItemGap = prop.FindPropertyRelative("m_ItemGap");
|
||||
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TitleModuleToggle, "Title", show);
|
||||
++EditorGUI.indentLevel;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_TitleModuleToggle)
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, text);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_TextFontSize, new GUIContent("Font Size"));
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, subText);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_SubTextFontSize, new GUIContent("Font Size"));
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ItemGap, new GUIContent("Item Gap"));
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, location);
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (m_TitleModuleToggle)
|
||||
{
|
||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
||||
height += EditorGUI.GetPropertyHeight(location);
|
||||
}
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/TitleDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/TitleDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22ae7ec778f27c1409cb9151ce7b9aba
|
||||
timeCreated: 1554304641
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Scripts/Editor/PropertyDrawers/TooltipDrawer.cs
Normal file
26
Scripts/Editor/PropertyDrawers/TooltipDrawer.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Tooltip), true)]
|
||||
public class TooltipDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_TooltipModuleToggle = false;
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
return 1 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/PropertyDrawers/TooltipDrawer.cs.meta
Normal file
13
Scripts/Editor/PropertyDrawers/TooltipDrawer.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5600b7009bc024a49800448cece012e2
|
||||
timeCreated: 1554419729
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Scripts/Editor/RadarChartEditor.cs
Normal file
28
Scripts/Editor/RadarChartEditor.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI RadarChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(RadarChart), false)]
|
||||
public class RadarChartEditor : BaseChartEditor
|
||||
{
|
||||
protected SerializedProperty m_Radar;
|
||||
protected bool m_RadarModuleToggle = false;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (RadarChart)target;
|
||||
m_Radar = serializedObject.FindProperty("m_Radar");
|
||||
}
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
{
|
||||
base.OnEndInspectorGUI();
|
||||
EditorGUILayout.PropertyField(m_Radar, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/RadarChartEditor.cs.meta
Normal file
13
Scripts/Editor/RadarChartEditor.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ea6609b1e1634241947b4ef14c38849
|
||||
timeCreated: 1555512890
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Scripts/Editor/Utility.meta
Normal file
10
Scripts/Editor/Utility.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb0b30c9bc2c84f46a99514a69d7e462
|
||||
folderAsset: yes
|
||||
timeCreated: 1555303340
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Scripts/Editor/Utility/ChartEditorHelper.cs
Normal file
113
Scripts/Editor/Utility/ChartEditorHelper.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class ChartEditorHelper
|
||||
{
|
||||
public static GUIStyle headerStyle = EditorStyles.boldLabel;
|
||||
public static GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout)
|
||||
{
|
||||
font = headerStyle.font,
|
||||
fontStyle = headerStyle.fontStyle,
|
||||
};
|
||||
|
||||
public static void SecondField(Rect drawRect, SerializedProperty prop)
|
||||
{
|
||||
RectOffset offset = new RectOffset(-(int)EditorGUIUtility.labelWidth, 0, 0, 0);
|
||||
drawRect = offset.Add(drawRect);
|
||||
EditorGUI.PropertyField(drawRect, prop, GUIContent.none);
|
||||
drawRect = offset.Remove(drawRect);
|
||||
}
|
||||
|
||||
public static void MakeJsonData(ref Rect drawRect, ref bool showTextArea, ref string inputString,
|
||||
SerializedProperty prop)
|
||||
{
|
||||
SerializedProperty stringDataProp = prop.FindPropertyRelative("m_JsonData");
|
||||
SerializedProperty needParseProp = prop.FindPropertyRelative("m_DataFromJson");
|
||||
float defalutX = drawRect.x;
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 40;
|
||||
drawRect.width = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 60;
|
||||
if (GUI.Button(drawRect, new GUIContent("Parse Json", "Parse data from input json")))
|
||||
{
|
||||
showTextArea = !showTextArea;
|
||||
bool needParse = !showTextArea;
|
||||
if (needParse)
|
||||
{
|
||||
stringDataProp.stringValue = inputString;
|
||||
needParseProp.boolValue = true;
|
||||
}
|
||||
}
|
||||
drawRect.x = defalutX;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (showTextArea)
|
||||
{
|
||||
drawRect.width = EditorGUIUtility.currentViewWidth - drawRect.x - 20;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight * 3;
|
||||
inputString = EditorGUI.TextArea(drawRect, inputString);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public static void MakeFoldout(ref Rect drawRect, ref bool moduleToggle, string content,
|
||||
SerializedProperty prop = null, bool bold = true)
|
||||
{
|
||||
float defaultWidth = drawRect.width;
|
||||
float defaultX = drawRect.x;
|
||||
drawRect.width = EditorGUIUtility.labelWidth;
|
||||
moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? foldoutStyle : EditorStyles.foldout);
|
||||
drawRect.x = EditorGUIUtility.labelWidth - (EditorGUI.indentLevel - 1) * 15 - 2;
|
||||
drawRect.width = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 70;
|
||||
if (prop != null)
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, prop, GUIContent.none);
|
||||
}
|
||||
drawRect.width = defaultWidth;
|
||||
drawRect.x = defaultX;
|
||||
}
|
||||
|
||||
public static void MakeList(ref Rect drawRect, ref int listSize, SerializedProperty listProp, SerializedProperty large = null)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
listSize = listProp.arraySize;
|
||||
listSize = EditorGUI.IntField(drawRect, "Size", listSize);
|
||||
if (listSize < 0) listSize = 0;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
if (listSize != listProp.arraySize)
|
||||
{
|
||||
while (listSize > listProp.arraySize)
|
||||
listProp.InsertArrayElementAtIndex(listProp.arraySize);
|
||||
while (listSize < listProp.arraySize)
|
||||
listProp.DeleteArrayElementAtIndex(listProp.arraySize - 1);
|
||||
}
|
||||
if (listSize > 50)
|
||||
{
|
||||
SerializedProperty element;
|
||||
int num = listSize > 10 ? 10 : listSize;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
element = listProp.GetArrayElementAtIndex(i);
|
||||
EditorGUI.PropertyField(drawRect, element);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (num >= 10)
|
||||
{
|
||||
EditorGUI.LabelField(drawRect, "...");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
element = listProp.GetArrayElementAtIndex(listSize - 1);
|
||||
EditorGUI.PropertyField(drawRect, element);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < listProp.arraySize; i++)
|
||||
{
|
||||
SerializedProperty element = listProp.GetArrayElementAtIndex(i);
|
||||
EditorGUI.PropertyField(drawRect, element);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
13
Scripts/Editor/Utility/ChartEditorHelper.cs.meta
Normal file
13
Scripts/Editor/Utility/ChartEditorHelper.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd22466b776d93c4cb0b252ee510cc7a
|
||||
timeCreated: 1555303340
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user