mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 05:50:09 +00:00
增加AxisName可配置XY轴名称
This commit is contained in:
@@ -46,6 +46,7 @@ namespace XCharts
|
||||
SerializedProperty m_SplitLineType = prop.FindPropertyRelative("m_SplitLineType");
|
||||
SerializedProperty m_BoundaryGap = prop.FindPropertyRelative("m_BoundaryGap");
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
|
||||
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
||||
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
|
||||
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
||||
@@ -103,6 +104,9 @@ namespace XCharts
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, m_BoundaryGap);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_AxisName);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisName);
|
||||
EditorGUI.PropertyField(drawRect, m_AxisTick);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisTick);
|
||||
@@ -132,8 +136,9 @@ namespace XCharts
|
||||
{
|
||||
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
||||
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
||||
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
|
||||
float height = 0;
|
||||
height += 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
|
||||
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
|
||||
if (type == Axis.AxisType.Category)
|
||||
{
|
||||
@@ -163,6 +168,7 @@ namespace XCharts
|
||||
height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
height += EditorGUI.GetPropertyHeight(m_AxisName);
|
||||
height += EditorGUI.GetPropertyHeight(m_AxisTick);
|
||||
return height;
|
||||
}
|
||||
|
||||
54
Scripts/Editor/PropertyDrawers/AxisNameDrawer.cs
Normal file
54
Scripts/Editor/PropertyDrawers/AxisNameDrawer.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Axis.AxisName), true)]
|
||||
public class AxisNameDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_AxisNameToggle = 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_Name = prop.FindPropertyRelative("m_Name");
|
||||
SerializedProperty m_Location = prop.FindPropertyRelative("m_Location");
|
||||
SerializedProperty m_Gap = prop.FindPropertyRelative("m_Gap");
|
||||
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
|
||||
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisNameToggle, "Axis Name", show, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_AxisNameToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Name);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Location);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Gap);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Rotate);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FontSize);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Color);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (m_AxisNameToggle)
|
||||
{
|
||||
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/PropertyDrawers/AxisNameDrawer.cs.meta
Normal file
11
Scripts/Editor/PropertyDrawers/AxisNameDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93f4873273d9c4d76bd651c8d774637f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user