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

81 lines
2.5 KiB
C#
Raw Normal View History

2021-12-24 13:33:09 +08:00

2020-05-21 08:32:52 +08:00
using System;
using UnityEngine;
using UnityEngine.UI;
2022-02-19 22:37:57 +08:00
namespace XCharts.Runtime
2020-05-21 08:32:52 +08:00
{
/// <summary>
2020-07-17 08:52:32 +08:00
/// Background component.
2022-03-24 08:37:06 +08:00
/// |
2020-05-21 08:32:52 +08:00
/// 背景组件。
/// </summary>
[Serializable]
2021-11-23 13:20:07 +08:00
[DisallowMultipleComponent]
[ComponentHandler(typeof(BackgroundHandler), false)]
2020-05-21 08:32:52 +08:00
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>
2022-03-24 08:37:06 +08:00
/// Whether to enable the background component.
/// |是否启用背景组件。
2020-05-21 08:32:52 +08:00
/// </summary>
public bool show
{
get { return m_Show; }
2021-01-11 08:54:28 +08:00
internal set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
2020-05-21 08:32:52 +08:00
}
/// <summary>
2020-07-17 08:52:32 +08:00
/// the image of background.
2022-03-24 08:37:06 +08:00
/// |背景图。
2020-05-21 08:32:52 +08:00
/// </summary>
public Sprite image
{
get { return m_Image; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetClass(ref m_Image, value)) SetComponentDirty(); }
2020-05-21 08:32:52 +08:00
}
/// <summary>
2020-07-17 08:52:32 +08:00
/// the fill type of background image.
2022-03-24 08:37:06 +08:00
/// |背景图填充类型。
2020-05-21 08:32:52 +08:00
/// </summary>
public Image.Type imageType
{
get { return m_ImageType; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
2020-05-21 08:32:52 +08:00
}
/// <summary>
/// 背景图颜色。
/// </summary>
public Color imageColor
{
get { return m_ImageColor; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
2020-05-21 08:32:52 +08:00
}
/// <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.
2022-03-24 08:37:06 +08:00
/// |当background组件开启时是否隐藏主题中设置的背景色。
2020-05-21 08:32:52 +08:00
/// </summary>
public bool hideThemeBackgroundColor
{
get { return m_HideThemeBackgroundColor; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetStruct(ref m_HideThemeBackgroundColor, value)) SetVerticesDirty(); }
2020-05-21 08:32:52 +08:00
}
2021-11-23 13:20:07 +08:00
public override void SetDefaultValue()
2020-05-21 08:32:52 +08:00
{
2022-03-29 22:06:10 +08:00
m_Show = true;
2021-11-23 13:20:07 +08:00
m_Image = null;
m_ImageType = Image.Type.Sliced;
m_ImageColor = Color.white;
m_HideThemeBackgroundColor = true;
2020-05-21 08:32:52 +08:00
}
}
}