mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 15:30:09 +00:00
增加LineArrow配置带箭头曲线
This commit is contained in:
55
Scripts/Editor/PropertyDrawers/LineArrowDrawer.cs
Normal file
55
Scripts/Editor/PropertyDrawers/LineArrowDrawer.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(LineArrow), true)]
|
||||
public class LineArrowStyleDrawer : PropertyDrawer
|
||||
{
|
||||
private Dictionary<string, bool> m_LineArrowToggle = 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_Position = prop.FindPropertyRelative("m_Position");
|
||||
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
|
||||
SerializedProperty m_Height = prop.FindPropertyRelative("m_Height");
|
||||
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
|
||||
SerializedProperty m_Dent = prop.FindPropertyRelative("m_Dent");
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_LineArrowToggle, prop, "Line Arrow", show, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (ChartEditorHelper.IsToggle(m_LineArrowToggle, prop))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Position);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Width);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Height);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Offset);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Dent);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (ChartEditorHelper.IsToggle(m_LineArrowToggle, prop))
|
||||
{
|
||||
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/PropertyDrawers/LineArrowDrawer.cs.meta
Normal file
11
Scripts/Editor/PropertyDrawers/LineArrowDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 817d27d232da94f6c9dab9e3d0c22631
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -24,6 +24,7 @@ namespace XCharts
|
||||
SerializedProperty m_AxisIndex = prop.FindPropertyRelative("m_AxisIndex");
|
||||
SerializedProperty m_RadarIndex = prop.FindPropertyRelative("m_RadarIndex");
|
||||
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||
SerializedProperty m_LineArrow = prop.FindPropertyRelative("m_LineArrow");
|
||||
SerializedProperty m_LineType = prop.FindPropertyRelative("m_LineType");
|
||||
SerializedProperty m_BarWidth = prop.FindPropertyRelative("m_BarWidth");
|
||||
SerializedProperty m_BarGap = prop.FindPropertyRelative("m_BarGap");
|
||||
@@ -132,6 +133,11 @@ namespace XCharts
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||
if (serieType == SerieType.Line)
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, m_LineArrow);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineArrow);
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, m_AreaStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
|
||||
EditorGUI.PropertyField(drawRect, m_Label, new GUIContent("Normal Label"));
|
||||
@@ -299,6 +305,7 @@ namespace XCharts
|
||||
}
|
||||
if (serieType == SerieType.Line)
|
||||
{
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (serieType == SerieType.Bar)
|
||||
|
||||
Reference in New Issue
Block a user