Files
XCharts/Runtime/Component/Main/Background.cs

106 lines
3.8 KiB
C#
Raw Normal View History

2020-05-21 08:32:52 +08:00
using System.Net.Mime;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
/// <summary>
2020-07-17 08:52:32 +08:00
/// Background component.
/// Due to the limitations of the framework, there are two limitations to the use of background component:
/// 1: The parent node of chart cannot have a layout control class component.
/// 2: The parent node of Chart can only have one child node of the current chart.
///
2020-05-21 08:32:52 +08:00
/// 背景组件。
/// 由于框架的局限性,背景组件使用有以下两个限制:
/// 1chart的父节点不能有布局控制类组件。
/// 2chart的父节点只能有当前chart一个子节点。
2020-05-21 08:32:52 +08:00
/// 背景组件的开启需要通过接口来开启BaseChart.EnableBackground(bool flag)
/// </summary>
[Serializable]
public class Background : MainComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private Sprite m_Image;
[SerializeField] private Image.Type m_ImageType;
[SerializeField] private Color m_ImageColor = Color.white;
[SerializeField] private bool m_HideThemeBackgroundColor = true;
/// <summary>
2020-07-17 08:52:32 +08:00
/// Whether to enable the background component. However,
/// the ability to activate the background component is subject to other conditions.
/// 是否启用背景组件。但能否激活背景组件还要受其他条件限制。
2020-05-21 08:32:52 +08:00
/// </summary>
public bool show
{
get { return m_Show; }
internal set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
2020-07-17 08:52:32 +08:00
/// the image of background.
2020-05-21 08:32:52 +08:00
/// 背景图。
/// </summary>
public Sprite image
{
get { return m_Image; }
set { if (PropertyUtility.SetClass(ref m_Image, value)) SetComponentDirty(); }
}
/// <summary>
2020-07-17 08:52:32 +08:00
/// the fill type of background image.
2020-05-21 08:32:52 +08:00
/// 背景图填充类型。
/// </summary>
public Image.Type imageType
{
get { return m_ImageType; }
set { if (PropertyUtility.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
}
/// <summary>
/// 背景图颜色。
/// </summary>
public Color imageColor
{
get { return m_ImageColor; }
set { if (PropertyUtility.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
}
/// <summary>
2020-07-17 08:52:32 +08:00
/// Whether to hide the background color set in the theme when the background component is on.
2020-05-21 08:32:52 +08:00
/// 当background组件开启时是否隐藏主题中设置的背景色。
/// </summary>
public bool hideThemeBackgroundColor
{
get { return m_HideThemeBackgroundColor; }
set { if (PropertyUtility.SetStruct(ref m_HideThemeBackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否已激活
/// </summary>
2020-07-17 08:52:32 +08:00
public bool runtimeActive { get; internal set; }
2020-05-21 08:32:52 +08:00
public static Background defaultBackground
{
get
{
var background = new Background
{
m_Show = false,
m_Image = null,
m_ImageType = Image.Type.Sliced,
m_ImageColor = Color.white,
m_HideThemeBackgroundColor = true,
};
return background;
}
}
}
}