修复Unity版本兼容问题

This commit is contained in:
monitor1394
2021-02-21 22:15:07 +08:00
parent 08f5a136c0
commit 8e5b6f159b
7 changed files with 18 additions and 15 deletions

View File

@@ -197,7 +197,7 @@ namespace XCharts
for (int i = 0; i < prop.arraySize; i++) for (int i = 0; i < prop.arraySize; i++)
{ {
EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(i), true); EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(i), true);
EditorGUILayout.Space(-EditorGUIUtility.singleLineHeight - EditorGUIUtility.standardVerticalSpacing); EditorGUILayout.Space();
var currRect = EditorGUILayout.GetControlRect(); var currRect = EditorGUILayout.GetControlRect();
var rect1 = new Rect(currRect.width + k_IconXOffset, var rect1 = new Rect(currRect.width + k_IconXOffset,

View File

@@ -165,13 +165,13 @@ namespace XCharts
else if (IsAssetsExist(XChartsMgr.GetThemeAssetPath(m_ChartName))) else if (IsAssetsExist(XChartsMgr.GetThemeAssetPath(m_ChartName)))
{ {
ShowNotification(new GUIContent("ERROR:The asset is exist! \npath=" ShowNotification(new GUIContent("ERROR:The asset is exist! \npath="
+ XChartsMgr.GetThemeAssetPath(m_ChartName)), 5); + XChartsMgr.GetThemeAssetPath(m_ChartName)));
} }
else else
{ {
XChartsMgr.ExportTheme(target.theme, m_ChartName); XChartsMgr.ExportTheme(target.theme, m_ChartName);
ShowNotification(new GUIContent("SUCCESS:The theme is exported. \npath=" ShowNotification(new GUIContent("SUCCESS:The theme is exported. \npath="
+ XChartsMgr.GetThemeAssetPath(m_ChartName)), 5); + XChartsMgr.GetThemeAssetPath(m_ChartName)));
} }
} }
} }

View File

@@ -15,6 +15,7 @@ public class ChartEditorHelper
public const float INDENT_WIDTH = 15; public const float INDENT_WIDTH = 15;
public const float BOOL_WIDTH = 15; public const float BOOL_WIDTH = 15;
public const float ARROW_WIDTH = 13; public const float ARROW_WIDTH = 13;
public const float BLOCK_WIDTH = 0;
public const float GAP_WIDTH = 0; public const float GAP_WIDTH = 0;
#endif #endif
@@ -26,8 +27,8 @@ public class ChartEditorHelper
font = headerStyle.font, font = headerStyle.font,
fontStyle = headerStyle.fontStyle, fontStyle = headerStyle.fontStyle,
}; };
public static readonly GUIContent iconAdd = EditorGUIUtility.TrIconContent("Toolbar Plus", "Add"); public static readonly GUIContent iconAdd = new GUIContent("+", "Add");
public static readonly GUIContent iconRemove = EditorGUIUtility.TrIconContent("Toolbar Minus", "Remove"); public static readonly GUIContent iconRemove = new GUIContent("-", "Remove");
public static readonly GUIContent iconUp = new GUIContent("↑", "Up"); public static readonly GUIContent iconUp = new GUIContent("↑", "Up");
public static readonly GUIContent iconDown = new GUIContent("↓", "Down"); public static readonly GUIContent iconDown = new GUIContent("↓", "Down");
public static readonly GUIStyle invisibleButton = "InvisibleButton"; public static readonly GUIStyle invisibleButton = "InvisibleButton";
@@ -286,20 +287,20 @@ public class ChartEditorHelper
{ {
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
var listSize = listProp.arraySize; var listSize = listProp.arraySize;
var iconWidth = 14; var iconWidth = 15;
var iconGap = 3f; var iconGap = 3f;
if (showSize) if (showSize)
{ {
if (showOrder) if (showOrder)
{ {
var temp = INDENT_WIDTH + GAP_WIDTH + iconGap; var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth - 1, drawRect.height); var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth + 2, drawRect.height);
var iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height); var iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
if (XChartsSettings.editorBlockEnable) if (XChartsSettings.editorBlockEnable)
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
if (GUI.Button(iconRect, Styles.iconAdd, Styles.invisibleButton)) if (GUI.Button(iconRect, Styles.iconAdd))
{ {
if (listProp.displayName.Equals("Series")) if (listProp.displayName.Equals("Series"))
{ {
@@ -361,7 +362,7 @@ public class ChartEditorHelper
var temp = INDENT_WIDTH + GAP_WIDTH + iconGap; var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
var isSerie = "Serie".Equals(element.type); var isSerie = "Serie".Equals(element.type);
var elementRect = isSerie var elementRect = isSerie
? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH, drawRect.height) ? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - iconGap, drawRect.height)
: new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height); : new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height);
EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i)); EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i));
var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
@@ -369,7 +370,7 @@ public class ChartEditorHelper
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
if (GUI.Button(iconRect, Styles.iconUp, Styles.invisibleButton)) if (GUI.Button(iconRect, Styles.iconUp))
{ {
if (i > 0) listProp.MoveArrayElement(i, i - 1); if (i > 0) listProp.MoveArrayElement(i, i - 1);
} }
@@ -378,7 +379,7 @@ public class ChartEditorHelper
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
if (GUI.Button(iconRect, Styles.iconDown, Styles.invisibleButton)) if (GUI.Button(iconRect, Styles.iconDown))
{ {
if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
} }
@@ -387,7 +388,7 @@ public class ChartEditorHelper
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
if (GUI.Button(iconRect, Styles.iconRemove, Styles.invisibleButton)) if (GUI.Button(iconRect, Styles.iconRemove))
{ {
if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i); if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i);
} }

View File

@@ -1,8 +1,7 @@
{ {
"name": "XCharts.Editor", "name": "XCharts.Editor",
"references": [ "references": [
"XCharts.Runtime", "XCharts.Runtime"
"Unity.TextMeshPro"
], ],
"includePlatforms": [ "includePlatforms": [
"Editor" "Editor"

View File

@@ -38,6 +38,7 @@ MonoBehaviour:
m_SerieScatterSymbolSize: 20 m_SerieScatterSymbolSize: 20
m_SerieScatterSymbolSelectedSize: 30 m_SerieScatterSymbolSelectedSize: 30
m_EditorBlockEnable: 1 m_EditorBlockEnable: 1
m_EditorShowAllListData: 0
m_MaxPainter: 10 m_MaxPainter: 10
m_LineSmoothStyle: 3 m_LineSmoothStyle: 3
m_LineSmoothness: 2 m_LineSmoothness: 2

View File

@@ -1,7 +1,6 @@
{ {
"name": "XCharts.Runtime", "name": "XCharts.Runtime",
"references": [ "references": [
"Unity.TextMeshPro"
], ],
"optionalUnityReferences": [], "optionalUnityReferences": [],
"includePlatforms": [], "includePlatforms": [],

View File

@@ -14,7 +14,10 @@ using TMPro;
namespace XCharts namespace XCharts
{ {
[Serializable] [Serializable]
#if UNITY_2018_3
[ExcludeFromPresetAttribute] [ExcludeFromPresetAttribute]
#endif
public class XChartsSettings : ScriptableObject public class XChartsSettings : ScriptableObject
{ {