diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index 9bf7e99f..e8fc55ab 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.02.11) 增加`Tooltip`的`backgroundImage`参数配置背景图 * (2020.02.11) 增加`Tooltip`的`paddingLeftRight`和`paddingTopBottom`参数配置文字和边框的间距 * (2020.02.11) 增加`Tooltip`的`lineStyle`参数配置指示线样式 * (2020.02.11) 增加`Axis`的`splitLine`参数控制分割线,去掉`showSplitLine`和`splitLineType`参数(更新时需要重新设置分割线相关设置) diff --git a/Assets/XCharts/Documentation/XCharts配置项手册.md b/Assets/XCharts/Documentation/XCharts配置项手册.md index 20ce7445..89ecafd9 100644 --- a/Assets/XCharts/Documentation/XCharts配置项手册.md +++ b/Assets/XCharts/Documentation/XCharts配置项手册.md @@ -198,6 +198,7 @@ * `paddingTopBottom`:文字和边框的上下边距。 * `fontSize`:文字的字体大小。 * `fontStyle`:文字的字体风格。 +* `backgroundImage`:提示框的背景图。 * `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。 * `lineStyle`:指示器线条样式 [LineStyle](#LineStyle)。 diff --git a/Assets/XCharts/Editor/PropertyDrawers/TooltipDrawer.cs b/Assets/XCharts/Editor/PropertyDrawers/TooltipDrawer.cs index 138055b8..50fe7255 100644 --- a/Assets/XCharts/Editor/PropertyDrawers/TooltipDrawer.cs +++ b/Assets/XCharts/Editor/PropertyDrawers/TooltipDrawer.cs @@ -33,6 +33,7 @@ namespace XCharts SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation"); SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight"); SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom"); + SerializedProperty m_BackgroundImage = prop.FindPropertyRelative("m_BackgroundImage"); SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle"); ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show); @@ -64,6 +65,8 @@ namespace XCharts drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_FontStyle); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_BackgroundImage); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_ForceENotation); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_LineStyle); @@ -75,7 +78,7 @@ namespace XCharts public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { if (m_TooltipModuleToggle) - return 14 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing + + return 15 * EditorGUIUtility.singleLineHeight + 14 * EditorGUIUtility.standardVerticalSpacing + EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")); else return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; diff --git a/Assets/XCharts/Runtime/Component/Main/Tooltip.cs b/Assets/XCharts/Runtime/Component/Main/Tooltip.cs index 062229ee..e7b081ed 100644 --- a/Assets/XCharts/Runtime/Component/Main/Tooltip.cs +++ b/Assets/XCharts/Runtime/Component/Main/Tooltip.cs @@ -60,11 +60,13 @@ namespace XCharts [SerializeField] private bool m_ForceENotation = false; [SerializeField] private float m_PaddingLeftRight = 5f; [SerializeField] private float m_PaddingTopBottom = 5f; + [SerializeField] private Sprite m_BackgroundImage; [SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid, 0.7f); private GameObject m_GameObject; private GameObject m_Content; private Text m_ContentText; + private Image m_ContentImage; private RectTransform m_ContentRect; private RectTransform m_ContentTextRect; private List lastDataIndex { get; set; } @@ -161,6 +163,11 @@ namespace XCharts /// public float paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } } /// + /// The image of icon. + /// 图标的图片。 + /// + public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetBackground(m_BackgroundImage); } } + /// /// 指示线样式。 /// public LineStyle lineStyle { get { return m_LineStyle; } set { if (value != null) m_LineStyle = value; } } @@ -240,11 +247,13 @@ namespace XCharts { m_Content = content; m_ContentRect = m_Content.GetComponent(); + m_ContentImage = m_Content.GetComponent(); m_ContentText = m_Content.GetComponentInChildren(); if (m_ContentText != null) { m_ContentTextRect = m_ContentText.gameObject.GetComponentInChildren(); } + SetBackground(backgroundImage); } /// @@ -263,8 +272,21 @@ namespace XCharts /// public void SetContentBackgroundColor(Color color) { - if (m_Content != null && m_Content.GetComponent() != null) - m_Content.GetComponent().color = color; + if (m_ContentImage != null) + m_ContentImage.color = color; + } + + /// + /// 设置提示框文本背景图片 + /// + /// + public void SetBackground(Sprite sprite) + { + if (m_ContentImage != null) + { + m_ContentImage.type = Image.Type.Sliced; + m_ContentImage.sprite = sprite; + } } /// diff --git a/Assets/XCharts/Runtime/Utility/XChartsMgr.cs b/Assets/XCharts/Runtime/Utility/XChartsMgr.cs index 3aeb055e..424d744b 100644 --- a/Assets/XCharts/Runtime/Utility/XChartsMgr.cs +++ b/Assets/XCharts/Runtime/Utility/XChartsMgr.cs @@ -25,7 +25,7 @@ namespace XCharts public class XChartsMgr : MonoBehaviour { public const string version = "1.2.0"; - public const int date = 20200210; + public const int date = 20200211; [SerializeField] private string m_NowVersion; [SerializeField] private string m_NewVersion;