mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 14:30:10 +00:00
XCharts 2.0
This commit is contained in:
@@ -13,8 +13,6 @@ namespace XCharts
|
||||
[CustomPropertyDrawer(typeof(Axis), true)]
|
||||
public class AxisDrawer : BasePropertyDrawer
|
||||
{
|
||||
private string m_JsonDataAreaText;
|
||||
|
||||
public override string ClassName { get { return "Axis"; } }
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
@@ -84,16 +82,7 @@ namespace XCharts
|
||||
|
||||
if (type == Axis.AxisType.Category)
|
||||
{
|
||||
m_DrawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
m_DataToggles[m_KeyName] = EditorGUI.Foldout(m_DrawRect, m_DataToggles[m_KeyName], "Data");
|
||||
AddSingleLineHeight();
|
||||
m_DrawRect.width = pos.width;
|
||||
if (m_DataToggles[m_KeyName])
|
||||
{
|
||||
var height = m_Heights[m_KeyName];
|
||||
ChartEditorHelper.MakeList(ref m_DrawRect, ref height, ref m_DataSize, m_Data);
|
||||
m_Heights[m_KeyName] = height;
|
||||
}
|
||||
PropertyListField(prop, "m_Data", true);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,18 @@ namespace XCharts
|
||||
m_DrawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
protected void PropertyListField(SerializedProperty prop, string relativePropName, bool showOrder = false)
|
||||
{
|
||||
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,
|
||||
prop.FindPropertyRelative(relativePropName),
|
||||
m_DataToggles.ContainsKey(toggleKeyName) && m_DataToggles[toggleKeyName], showOrder);
|
||||
m_Heights[m_KeyName] = height;
|
||||
}
|
||||
|
||||
protected void PropertyField(SerializedProperty prop, string relativePropName)
|
||||
{
|
||||
if (IngorePropertys.Contains(relativePropName)) return;
|
||||
|
||||
@@ -49,14 +49,14 @@ namespace XCharts
|
||||
PropertyField(prop, "m_Bottom");
|
||||
PropertyField(prop, "m_LineStyle");
|
||||
PropertyField(prop, "m_AreaStyle");
|
||||
PropertyField(prop, "m_XAxisIndexs");
|
||||
PropertyField(prop, "m_YAxisIndexs");
|
||||
PropertyListField(prop, "m_XAxisIndexs", true);
|
||||
PropertyListField(prop, "m_YAxisIndexs", true);
|
||||
PropertyField(prop, "m_TextStyle");
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyField(prop, "m_XAxisIndexs");
|
||||
PropertyField(prop, "m_YAxisIndexs");
|
||||
PropertyListField(prop, "m_XAxisIndexs", true);
|
||||
PropertyListField(prop, "m_YAxisIndexs", true);
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace XCharts
|
||||
PropertyField(prop, "m_Opacity");
|
||||
PropertyField(prop, "m_TooltipFormatter");
|
||||
PropertyField(prop, "m_NumericFormatter");
|
||||
PropertyField(prop, "m_CornerRadius");
|
||||
PropertyListField(prop, "m_CornerRadius", true);
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,6 @@ 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)
|
||||
@@ -23,15 +20,8 @@ namespace XCharts
|
||||
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;
|
||||
drawRect.width = pos.width;
|
||||
if (m_SeriesModuleToggle)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Series, true);
|
||||
}
|
||||
m_SeriesModuleToggle = ChartEditorHelper.MakeListWithFoldout(ref drawRect,
|
||||
m_Series, m_SeriesModuleToggle, true, true);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
@@ -46,10 +36,6 @@ namespace XCharts
|
||||
height += EditorGUI.GetPropertyHeight(m_Data.GetArrayElementAtIndex(i)) + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
if (m_ShowJsonDataArea)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return height;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,9 @@ namespace XCharts
|
||||
if (newProp.name == "m_Script") continue;
|
||||
if (newProp.name == "m_ThemeName") continue;
|
||||
if (newProp.name == "m_Theme") continue;
|
||||
|
||||
AddPropertyField(pos, newProp, ref y);
|
||||
|
||||
} while (newProp.NextVisible(false));
|
||||
}
|
||||
if (GUI.changed)
|
||||
|
||||
@@ -255,24 +255,46 @@ public class ChartEditorHelper
|
||||
return toggle;
|
||||
}
|
||||
|
||||
public static void MakeList(ref Rect drawRect, ref int listSize, SerializedProperty listProp, bool showOrder = false, bool showSize = true)
|
||||
public static bool MakeListWithFoldout(ref Rect drawRect, SerializedProperty listProp, bool foldout, bool showOrder = false, bool showSize = true)
|
||||
{
|
||||
var height = 0f;
|
||||
MakeList(ref drawRect, ref height, ref listSize, listProp, showOrder, showSize);
|
||||
return MakeListWithFoldout(ref drawRect, ref height, listProp, foldout, showOrder, showSize);
|
||||
}
|
||||
|
||||
public static void MakeList(ref Rect drawRect, ref float height, ref int listSize, SerializedProperty listProp, bool showOrder = false, bool showSize = true)
|
||||
public static bool MakeListWithFoldout(ref Rect drawRect, ref float height, SerializedProperty listProp, bool foldout, bool showOrder = false, bool showSize = true)
|
||||
{
|
||||
var rawWidth = drawRect.width;
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
bool flag = EditorGUI.Foldout(drawRect, foldout, listProp.displayName);
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.width = rawWidth;
|
||||
if (flag)
|
||||
{
|
||||
MakeList(ref drawRect, ref height, listProp, showOrder, showSize);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static void MakeList(ref Rect drawRect, SerializedProperty listProp, bool showOrder = false, bool showSize = true)
|
||||
{
|
||||
var height = 0f;
|
||||
MakeList(ref drawRect, ref height, listProp, showOrder, showSize);
|
||||
}
|
||||
|
||||
public static void MakeList(ref Rect drawRect, ref float height, SerializedProperty listProp, bool showOrder = false, bool showSize = true)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
listSize = listProp.arraySize;
|
||||
var listSize = listProp.arraySize;
|
||||
var iconWidth = 14;
|
||||
var iconGap = 3f;
|
||||
if (showSize)
|
||||
{
|
||||
if (showOrder)
|
||||
{
|
||||
var nameWid = 18;
|
||||
var temp = INDENT_WIDTH + GAP_WIDTH;
|
||||
var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - nameWid - 1, drawRect.height);
|
||||
var iconRect = new Rect(drawRect.width - nameWid + temp, drawRect.y, nameWid, drawRect.height);
|
||||
var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
|
||||
var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth - 1, drawRect.height);
|
||||
var iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
|
||||
if (XChartsSettings.editorBlockEnable)
|
||||
{
|
||||
iconRect.x += BLOCK_WIDTH;
|
||||
@@ -335,12 +357,14 @@ public class ChartEditorHelper
|
||||
SerializedProperty element = listProp.GetArrayElementAtIndex(i);
|
||||
if (showOrder)
|
||||
{
|
||||
var nameWid = 18;
|
||||
var temp = INDENT_WIDTH + GAP_WIDTH;
|
||||
|
||||
var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
|
||||
var isSerie = "Serie".Equals(element.type);
|
||||
var elementRect = isSerie ? drawRect : new Rect(drawRect.x, drawRect.y, drawRect.width - 2 * nameWid, drawRect.height);
|
||||
var elementRect = isSerie
|
||||
? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH, drawRect.height)
|
||||
: new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height);
|
||||
EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i));
|
||||
var iconRect = new Rect(drawRect.width - 3 * nameWid + temp, drawRect.y, nameWid, drawRect.height);
|
||||
var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
|
||||
if (XChartsSettings.editorBlockEnable)
|
||||
{
|
||||
iconRect.x += BLOCK_WIDTH;
|
||||
@@ -349,7 +373,7 @@ public class ChartEditorHelper
|
||||
{
|
||||
if (i > 0) listProp.MoveArrayElement(i, i - 1);
|
||||
}
|
||||
iconRect = new Rect(drawRect.width - 2 * nameWid + temp, drawRect.y, nameWid, drawRect.height);
|
||||
iconRect = new Rect(drawRect.width - 2 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
|
||||
if (XChartsSettings.editorBlockEnable)
|
||||
{
|
||||
iconRect.x += BLOCK_WIDTH;
|
||||
@@ -358,7 +382,7 @@ public class ChartEditorHelper
|
||||
{
|
||||
if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
|
||||
}
|
||||
iconRect = new Rect(drawRect.width - nameWid + temp, drawRect.y, nameWid, drawRect.height);
|
||||
iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
|
||||
if (XChartsSettings.editorBlockEnable)
|
||||
{
|
||||
iconRect.x += BLOCK_WIDTH;
|
||||
@@ -384,82 +408,6 @@ public class ChartEditorHelper
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
public static void MakeList(ref int listSize, SerializedProperty listProp, bool showOrder = false, bool showSize = true)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
listSize = listProp.arraySize;
|
||||
if (showSize)
|
||||
{
|
||||
if (showOrder)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
listSize = EditorGUILayout.IntField("Size", listSize);
|
||||
if (GUILayout.Button(Styles.iconAdd, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15)))
|
||||
{
|
||||
listProp.arraySize++;
|
||||
}
|
||||
listSize = listProp.arraySize;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
else
|
||||
{
|
||||
listSize = EditorGUILayout.IntField("Size", listSize);
|
||||
}
|
||||
if (listSize < 0) listSize = 0;
|
||||
if (listSize != listProp.arraySize)
|
||||
{
|
||||
while (listSize > listProp.arraySize) listProp.arraySize++;
|
||||
while (listSize < listProp.arraySize) listProp.arraySize--;
|
||||
}
|
||||
}
|
||||
if (listSize > 30)
|
||||
{
|
||||
SerializedProperty element;
|
||||
int num = listSize > 10 ? 10 : listSize;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
element = listProp.GetArrayElementAtIndex(i);
|
||||
EditorGUILayout.PropertyField(element, true);
|
||||
}
|
||||
if (num >= 10)
|
||||
{
|
||||
EditorGUILayout.LabelField("...");
|
||||
element = listProp.GetArrayElementAtIndex(listSize - 1);
|
||||
EditorGUILayout.PropertyField(element, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < listProp.arraySize; i++)
|
||||
{
|
||||
SerializedProperty element = listProp.GetArrayElementAtIndex(i);
|
||||
if (showOrder)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PropertyField(element, true);
|
||||
if (GUILayout.Button(Styles.iconUp, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15)))
|
||||
{
|
||||
if (i > 0) listProp.MoveArrayElement(i, i - 1);
|
||||
}
|
||||
if (GUILayout.Button(Styles.iconDown, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15)))
|
||||
{
|
||||
if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
|
||||
}
|
||||
if (GUILayout.Button(Styles.iconRemove, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15)))
|
||||
{
|
||||
if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(element, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key, SerializedProperty prop)
|
||||
{
|
||||
if (prop == null)
|
||||
|
||||
@@ -55,6 +55,9 @@ namespace XCharts
|
||||
[SerializeField] private Color32 m_ContrastColor;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
|
||||
#if UNITY_2020_2
|
||||
[NonReorderable]
|
||||
#endif
|
||||
[SerializeField] private List<Color32> m_ColorPalette = new List<Color32>(13);
|
||||
|
||||
[SerializeField] private ComponentTheme m_Common;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace XCharts
|
||||
public class XChartsMgr : MonoBehaviour
|
||||
{
|
||||
internal static string _version = "2.0.0";
|
||||
internal static int _versionDate = 20210110;
|
||||
internal static int _versionDate = 20210117;
|
||||
public static string version { get { return _version; } }
|
||||
public static int versionDate { get { return _versionDate; } }
|
||||
public static string fullVersion { get { return version + "_" + versionDate; } }
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"name": "com.monitor1394.xcharts",
|
||||
"displayName": "XCharts",
|
||||
"version": "2.0.0",
|
||||
"date": "20210110",
|
||||
"checkdate": "20210110",
|
||||
"date": "20210117",
|
||||
"checkdate": "20210117",
|
||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||
"unity": "2018.3",
|
||||
"description": "A charting and data visualization library for Unity.",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"date": "20210110",
|
||||
"checkdate": "20210110",
|
||||
"date": "20210117",
|
||||
"checkdate": "20210117",
|
||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
|
||||
}
|
||||
Reference in New Issue
Block a user