mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 05:50:09 +00:00
XCharts 2.0
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Text;
|
||||
@@ -45,6 +46,7 @@ namespace XCharts
|
||||
|
||||
private bool m_BaseFoldout;
|
||||
protected bool m_ShowAllComponent;
|
||||
protected Dictionary<string, bool> m_Flodouts = new Dictionary<string, bool>();
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
@@ -140,8 +142,6 @@ namespace XCharts
|
||||
|
||||
protected virtual void OnDebugInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
BlockStart();
|
||||
EditorGUILayout.PropertyField(m_DebugMode);
|
||||
EditorGUILayout.PropertyField(m_MultiComponentMode);
|
||||
@@ -181,7 +181,46 @@ namespace XCharts
|
||||
BlockStart();
|
||||
foreach (var prop in props)
|
||||
{
|
||||
if (all) EditorGUILayout.PropertyField(prop, true);
|
||||
if (all)
|
||||
{
|
||||
var flag = m_Flodouts.ContainsKey(prop.displayName) && m_Flodouts[prop.displayName];
|
||||
m_Flodouts[prop.displayName] = EditorGUILayout.Foldout(flag, prop.displayName);
|
||||
if (m_Flodouts[prop.displayName])
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
prop.arraySize = EditorGUILayout.IntField("Size", prop.arraySize);
|
||||
for (int i = 0; i < prop.arraySize; i++)
|
||||
{
|
||||
SerializedProperty element = prop.GetArrayElementAtIndex(i);
|
||||
var currRect = EditorGUILayout.GetControlRect();
|
||||
var iconWidth = 14;
|
||||
var iconGap = 0f;
|
||||
var xDiff = 10f;
|
||||
var yDiff = 3f;
|
||||
var rect1 = new Rect(currRect.width + xDiff, currRect.y + yDiff,
|
||||
iconWidth, EditorGUIUtility.singleLineHeight);
|
||||
if (GUI.Button(rect1, ChartEditorHelper.Styles.iconRemove, ChartEditorHelper.Styles.invisibleButton))
|
||||
{
|
||||
if (i < prop.arraySize && i >= 0) prop.DeleteArrayElementAtIndex(i);
|
||||
}
|
||||
var rect2 = new Rect(currRect.width + xDiff - iconWidth - iconGap, currRect.y + yDiff,
|
||||
iconWidth, EditorGUIUtility.singleLineHeight);
|
||||
if (GUI.Button(rect2, ChartEditorHelper.Styles.iconDown, ChartEditorHelper.Styles.invisibleButton))
|
||||
{
|
||||
if (i < prop.arraySize - 1) prop.MoveArrayElement(i, i + 1);
|
||||
}
|
||||
var rect3 = new Rect(currRect.width + xDiff - 2 * (iconWidth + iconGap), currRect.y + yDiff,
|
||||
iconWidth, EditorGUIUtility.singleLineHeight);
|
||||
if (GUI.Button(rect3, ChartEditorHelper.Styles.iconUp, ChartEditorHelper.Styles.invisibleButton))
|
||||
{
|
||||
if (i > 0) prop.MoveArrayElement(i, i - 1);
|
||||
}
|
||||
EditorGUILayout.Space(-EditorGUIUtility.singleLineHeight - EditorGUIUtility.standardVerticalSpacing);
|
||||
EditorGUILayout.PropertyField(element, true);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
else if (prop.arraySize > 0) EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(0), true);
|
||||
}
|
||||
BlockEnd();
|
||||
@@ -199,7 +238,7 @@ namespace XCharts
|
||||
{
|
||||
m_Chart.RemoveChartObject();
|
||||
}
|
||||
if (GUILayout.Button("Check XCharts Update "))
|
||||
if (GUILayout.Button("Check XCharts Update"))
|
||||
{
|
||||
CheckVersionEditor.ShowWindow();
|
||||
}
|
||||
|
||||
@@ -86,10 +86,9 @@ namespace XCharts
|
||||
m_DrawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
protected void PropertyListField(SerializedProperty prop, string relativePropName, bool showOrder = false)
|
||||
protected void PropertyListField(SerializedProperty prop, string relativePropName, bool showOrder = true)
|
||||
{
|
||||
if (IngorePropertys.Contains(relativePropName)) return;
|
||||
|
||||
var height = m_Heights[m_KeyName];
|
||||
var toggleKeyName = m_KeyName + relativePropName;
|
||||
m_DataToggles[toggleKeyName] = ChartEditorHelper.MakeListWithFoldout(ref m_DrawRect, ref height,
|
||||
@@ -101,6 +100,11 @@ namespace XCharts
|
||||
protected void PropertyField(SerializedProperty prop, string relativePropName)
|
||||
{
|
||||
if (IngorePropertys.Contains(relativePropName)) return;
|
||||
if (prop.FindPropertyRelative(relativePropName).isArray)
|
||||
{
|
||||
PropertyListField(prop, relativePropName);
|
||||
return;
|
||||
}
|
||||
if (!ChartEditorHelper.PropertyField(ref m_DrawRect, m_Heights, m_KeyName, prop, relativePropName))
|
||||
{
|
||||
Debug.LogError("PropertyField ERROR:" + prop.displayName + ", " + relativePropName);
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace XCharts
|
||||
PropertyField(prop, "m_Location");
|
||||
PropertyField(prop, "m_Formatter");
|
||||
PropertyField(prop, "m_TextStyle");
|
||||
PropertyField(prop, "m_Icons");
|
||||
PropertyListField(prop, "m_Icons");
|
||||
PropertyListField(prop, "m_Data");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace XCharts
|
||||
PropertyField(prop, "m_Max");
|
||||
PropertyField(prop, "m_SplitNumber");
|
||||
PropertyField(prop, "m_Dimension");
|
||||
PropertyField(prop, "m_InRange");
|
||||
PropertyField(prop, "m_OutOfRange");
|
||||
PropertyListField(prop, "m_InRange");
|
||||
PropertyListField(prop, "m_OutOfRange");
|
||||
PropertyField(prop, "m_Show");
|
||||
if (prop.FindPropertyRelative("m_Show").boolValue)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ChartEditorHelper
|
||||
public const float GAP_WIDTH = 0;
|
||||
#endif
|
||||
|
||||
private class Styles
|
||||
public class Styles
|
||||
{
|
||||
public static readonly GUIStyle headerStyle = EditorStyles.boldLabel;
|
||||
public static readonly GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout)
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 多列时每列的宽度
|
||||
/// </summary>
|
||||
public Dictionary<int, float> runtimeEachWidth { get { return m_RuntimeEachWidth; }}
|
||||
public Dictionary<int, float> runtimeEachWidth { get { return m_RuntimeEachWidth; } }
|
||||
/// <summary>
|
||||
/// 单列高度
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user