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; } }
///
/// the theme of chart.
/// ||主题类型。
///
public ThemeType themeType
{
get { return sharedTheme.themeType; }
}
///
/// theme name.
/// ||主题名字。
///
public string themeName
{
get { return sharedTheme.themeName; }
}
///
/// the asset of theme.
/// ||主题配置。
///
public Theme sharedTheme
{
get { return m_SharedTheme; }
set { m_SharedTheme = value; SetAllDirty(); }
}
///
/// the background color of chart.
/// ||背景颜色。
///
public Color32 backgroundColor
{
get
{
if (m_TransparentBackground) return ColorUtil.clearColor32;
else if (sharedTheme != null) return sharedTheme.backgroundColor;
else return ColorUtil.clearColor32;
}
}
public Color32 GetBackgroundColor(Background background)
{
if (background != null && background.show && !background.autoColor)
return background.imageColor;
else
return backgroundColor;
}
}
}