优化结构,分离为XCharts和XChartsDemo两部分

This commit is contained in:
monitor1394
2019-11-09 07:00:58 +08:00
parent aef05a53ef
commit d45e2695a5
17 changed files with 6392 additions and 46 deletions

View File

@@ -0,0 +1,45 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XChartsDemo
{
[CustomPropertyDrawer(typeof(ChartModule), true)]
public class ChartModuleDrawer : PropertyDrawer
{
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
var lastX = drawRect.x;
var lastWid = drawRect.width;
SerializedProperty m_Name = prop.FindPropertyRelative("m_Name");
SerializedProperty m_Title = prop.FindPropertyRelative("m_Title");
SerializedProperty m_Selected = prop.FindPropertyRelative("m_Selected");
SerializedProperty m_Panel = prop.FindPropertyRelative("m_Panel");
var fieldWid = EditorGUIUtility.currentViewWidth - 30 - 5 - 50 - 90;
drawRect.width = 15;
EditorGUI.PropertyField(drawRect,m_Selected,GUIContent.none);
drawRect.x += 15;
drawRect.width = 50;
EditorGUI.PropertyField(drawRect,m_Name,GUIContent.none);
drawRect.x += 52;
drawRect.width = fieldWid;
EditorGUI.PropertyField(drawRect,m_Title,GUIContent.none);
drawRect.x += fieldWid + 2;
drawRect.width = 90;
EditorGUI.PropertyField(drawRect,m_Panel,GUIContent.none);
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2fbbaed3e670f478c844c1bdfc73d433
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@

/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XChartsDemo
{
/// <summary>
/// Editor class used to edit UI BaseChart.
/// </summary>
[CustomEditor(typeof(Demo), false)]
public class DemoEditor : Editor
{
protected Demo m_Target;
protected SerializedProperty m_Script;
protected SerializedProperty m_ButtonNormalColor;
protected SerializedProperty m_ButtonSelectedColor;
protected SerializedProperty m_ButtonHighlightColor;
protected SerializedProperty m_ChartModule;
protected virtual void OnEnable()
{
m_Target = (Demo)target;
m_Script = serializedObject.FindProperty("m_Script");
m_ButtonNormalColor = serializedObject.FindProperty("m_ButtonNormalColor");
m_ButtonSelectedColor = serializedObject.FindProperty("m_ButtonSelectedColor");
m_ButtonHighlightColor = serializedObject.FindProperty("m_ButtonHighlightColor");
m_ChartModule = serializedObject.FindProperty("m_ChartModule");
}
public override void OnInspectorGUI()
{
if (m_Target == null && target == null)
{
base.OnInspectorGUI();
return;
}
serializedObject.Update();
EditorGUILayout.PropertyField(m_ButtonNormalColor);
EditorGUILayout.PropertyField(m_ButtonSelectedColor);
EditorGUILayout.PropertyField(m_ButtonHighlightColor);
var size = m_ChartModule.arraySize;
size = EditorGUILayout.IntField("Chart Module Size", size);
if (size != m_ChartModule.arraySize)
{
while (size > m_ChartModule.arraySize)
m_ChartModule.InsertArrayElementAtIndex(m_ChartModule.arraySize);
while (size < m_ChartModule.arraySize)
m_ChartModule.DeleteArrayElementAtIndex(m_ChartModule.arraySize - 1);
}
for (int i = 0; i < size; i++)
{
EditorGUILayout.PropertyField(m_ChartModule.GetArrayElementAtIndex(i));
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 90c1787bea03849c8b6d19be625b7e17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: