mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
增加Background背景组件
This commit is contained in:
@@ -23,6 +23,7 @@ namespace XCharts
|
||||
protected SerializedProperty m_ChartHeight;
|
||||
protected SerializedProperty m_Theme;
|
||||
protected SerializedProperty m_ThemeInfo;
|
||||
protected SerializedProperty m_Background;
|
||||
protected SerializedProperty m_Title;
|
||||
protected SerializedProperty m_Legend;
|
||||
protected SerializedProperty m_Tooltip;
|
||||
@@ -30,6 +31,7 @@ namespace XCharts
|
||||
protected SerializedProperty m_Settings;
|
||||
protected SerializedProperty m_Large;
|
||||
protected SerializedProperty m_ChartName;
|
||||
protected SerializedProperty m_DebugMode;
|
||||
|
||||
protected float m_DefaultLabelWidth;
|
||||
protected float m_DefaultFieldWidth;
|
||||
@@ -46,6 +48,7 @@ namespace XCharts
|
||||
m_ChartHeight = serializedObject.FindProperty("m_ChartHeight");
|
||||
m_Theme = serializedObject.FindProperty("m_Theme");
|
||||
m_ThemeInfo = serializedObject.FindProperty("m_ThemeInfo");
|
||||
m_Background = serializedObject.FindProperty("m_Background");
|
||||
m_Title = serializedObject.FindProperty("m_Title");
|
||||
m_Legend = serializedObject.FindProperty("m_Legend");
|
||||
m_Tooltip = serializedObject.FindProperty("m_Tooltip");
|
||||
@@ -53,6 +56,7 @@ namespace XCharts
|
||||
|
||||
m_Large = serializedObject.FindProperty("m_Large");
|
||||
m_Settings = serializedObject.FindProperty("m_Settings");
|
||||
m_DebugMode = serializedObject.FindProperty("m_DebugMode");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
@@ -70,6 +74,7 @@ namespace XCharts
|
||||
OnMiddleInspectorGUI();
|
||||
OnEndInspectorGUI();
|
||||
|
||||
EditorGUILayout.PropertyField(m_DebugMode);
|
||||
CheckWarning();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -77,9 +82,17 @@ namespace XCharts
|
||||
protected virtual void OnStartInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_Script);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(m_ChartName);
|
||||
EditorGUILayout.PropertyField(m_ThemeInfo, true);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_Background, true);
|
||||
|
||||
var m_Show = m_Background.FindPropertyRelative("m_Show");
|
||||
if (m_Show.boolValue && !m_Target.CanShowBackgroundComponent())
|
||||
{
|
||||
EditorGUILayout.HelpBox("can't show background component:chart is control by LayoutGroup.", MessageType.Warning);
|
||||
}
|
||||
EditorGUILayout.PropertyField(m_Title, true);
|
||||
EditorGUILayout.PropertyField(m_Legend, true);
|
||||
EditorGUILayout.PropertyField(m_Tooltip, true);
|
||||
|
||||
67
Editor/PropertyDrawers/BackgroundDrawer.cs
Normal file
67
Editor/PropertyDrawers/BackgroundDrawer.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Background), true)]
|
||||
public class BackgroundDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_BackgroundModuleToggle = false;
|
||||
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
|
||||
SerializedProperty m_Image = prop.FindPropertyRelative("m_Image");
|
||||
SerializedProperty m_ImageType = prop.FindPropertyRelative("m_ImageType");
|
||||
// SerializedProperty m_Left = prop.FindPropertyRelative("m_Left");
|
||||
// SerializedProperty m_Right = prop.FindPropertyRelative("m_Right");
|
||||
// SerializedProperty m_Top = prop.FindPropertyRelative("m_Top");
|
||||
// SerializedProperty m_Bottom = prop.FindPropertyRelative("m_Bottom");
|
||||
SerializedProperty m_ImageColor = prop.FindPropertyRelative("m_ImageColor");
|
||||
SerializedProperty m_HideThemeBackgroundColor = prop.FindPropertyRelative("m_HideThemeBackgroundColor");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_BackgroundModuleToggle, "Background", m_Show);
|
||||
EditorGUI.LabelField(drawRect, "Background", EditorStyles.boldLabel);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_BackgroundModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Image);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ImageType);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, m_Left);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, m_Right);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, m_Top);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, m_Bottom);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ImageColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_HideThemeBackgroundColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_BackgroundModuleToggle)
|
||||
return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
else
|
||||
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/PropertyDrawers/BackgroundDrawer.cs.meta
Normal file
11
Editor/PropertyDrawers/BackgroundDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24e3f8609cdf9494cb350a110566176f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user