Files
XCharts/Runtime/Internal/UIComponentTheme.cs

62 lines
1.7 KiB
C#
Raw Normal View History

2023-03-20 21:56:56 +08:00
using System;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime
{
[Serializable]
public class UIComponentTheme : ChildComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private Theme m_SharedTheme;
[SerializeField] private bool m_TransparentBackground = false;
public bool show { get { return m_Show; } }
/// <summary>
/// the theme of chart.
2023-11-11 23:32:24 +08:00
/// ||主题类型。
2023-03-20 21:56:56 +08:00
/// </summary>
public ThemeType themeType
{
get { return sharedTheme.themeType; }
}
/// <summary>
/// theme name.
2023-11-11 23:32:24 +08:00
/// ||主题名字。
2023-03-20 21:56:56 +08:00
/// </summary>
public string themeName
{
get { return sharedTheme.themeName; }
}
/// <summary>
/// the asset of theme.
2023-11-11 23:32:24 +08:00
/// ||主题配置。
2023-03-20 21:56:56 +08:00
/// </summary>
public Theme sharedTheme
{
get { return m_SharedTheme; }
set { m_SharedTheme = value; SetAllDirty(); }
}
/// <summary>
/// the background color of chart.
2023-11-11 23:32:24 +08:00
/// ||背景颜色。
2023-03-20 21:56:56 +08:00
/// </summary>
public Color32 backgroundColor
{
get
{
if (m_TransparentBackground) return ColorUtil.clearColor32;
2023-11-01 08:53:18 +08:00
else if (sharedTheme != null) return sharedTheme.backgroundColor;
else return ColorUtil.clearColor32;
2023-03-20 21:56:56 +08:00
}
}
2024-01-16 22:29:15 +08:00
public Color32 GetBackgroundColor(Background background)
{
if (background != null && background.show && !background.autoColor)
return background.imageColor;
else
return backgroundColor;
}
2023-03-20 21:56:56 +08:00
}
}