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

79 lines
2.5 KiB
C#
Raw Normal View History

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-12-07 13:16: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_AutoColor = true;
2020-05-21 08:32:52 +08:00
/// <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; }
2022-12-07 13:16:06 +08:00
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>
/// Whether to use theme background color for component color when the background component is on.
/// |当background组件开启时是否自动使用主题背景色作为backgrounnd组件的颜色。当设置为false时用imageColor作为颜色。
2020-05-21 08:32:52 +08:00
/// </summary>
public bool autoColor
2020-05-21 08:32:52 +08:00
{
get { return m_AutoColor; }
set { if (PropertyUtil.SetStruct(ref m_AutoColor, 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_AutoColor = true;
2020-05-21 08:32:52 +08:00
}
}
}