This commit is contained in:
monitor1394
2022-03-30 08:24:47 +08:00
parent 1ad87920d0
commit 4ade064266
3 changed files with 23 additions and 17 deletions

View File

@@ -44,6 +44,7 @@ namespace XCharts.Editor
XCThemeMgr.SwitchTheme(chart, chartNameList[selectedIndex]); XCThemeMgr.SwitchTheme(chart, chartNameList[selectedIndex]);
} }
PropertyField(prop, "m_SharedTheme"); PropertyField(prop, "m_SharedTheme");
PropertyField(prop, "m_TransparentBackground");
PropertyField(prop, "m_EnableCustomTheme"); PropertyField(prop, "m_EnableCustomTheme");
using (new EditorGUI.DisabledScope(!prop.FindPropertyRelative("m_EnableCustomTheme").boolValue)) using (new EditorGUI.DisabledScope(!prop.FindPropertyRelative("m_EnableCustomTheme").boolValue))
{ {

View File

@@ -193,20 +193,5 @@ namespace XCharts.Editor
XChartsMgr.ModifyTMPRefence(true); XChartsMgr.ModifyTMPRefence(true);
XChartsMgr.DisableTextMeshPro(); XChartsMgr.DisableTextMeshPro();
} }
[MenuItem("XCharts/Theme/Export Default Theme")]
public static void ExportDefaultTheme()
{
var profile = ScriptableObject.CreateInstance<Theme>();
profile.name = "Default";
profile.themeName = "Default";
profile.themeType = ThemeType.Default;
var themeName = XCSettings.THEME_ASSET_NAME_PREFIX + profile.themeName;
var path = XCSettings.THEME_ASSET_FOLDER + "/" + themeName + ".asset";
AssetDatabase.CreateAsset(profile, path);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
} }
} }

View File

@@ -41,7 +41,8 @@ namespace XCharts.Runtime
{ {
[SerializeField] private bool m_Show = true; [SerializeField] private bool m_Show = true;
[SerializeField] private Theme m_SharedTheme; [SerializeField] private Theme m_SharedTheme;
[SerializeField] private bool m_EnableCustomTheme; [SerializeField] private bool m_TransparentBackground = false;
[SerializeField] private bool m_EnableCustomTheme = false;
[SerializeField] private Font m_CustomFont; [SerializeField] private Font m_CustomFont;
[SerializeField] private Color32 m_CustomBackgroundColor; [SerializeField] private Color32 m_CustomBackgroundColor;
#if UNITY_2020_2 #if UNITY_2020_2
@@ -83,8 +84,27 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public Color32 backgroundColor public Color32 backgroundColor
{ {
get { return m_EnableCustomTheme ? m_CustomBackgroundColor : sharedTheme.backgroundColor; } get
{
if (m_TransparentBackground) return ColorUtil.clearColor32;
else return m_EnableCustomTheme ? m_CustomBackgroundColor : sharedTheme.backgroundColor;
}
} }
/// <summary>
/// Whether the background color is transparent. When true, the background color is not drawn.
/// 是否透明背景颜色。当设置为true时不绘制背景颜色。
/// </summary>
public bool transparentBackground
{
get { return m_TransparentBackground; }
set { m_TransparentBackground = value; SetAllDirty(); }
}
/// <summary>
/// Whether to customize theme colors. When set to true,
/// you can use 'sync color to custom' to synchronize the theme color to the custom color. It can also be set manually.
/// |是否自定义主题颜色。当设置为true时可以用sync color to custom同步主题的颜色到自定义颜色。也可以手动设置。
/// </summary>
/// <value></value>
public bool enableCustomTheme public bool enableCustomTheme
{ {
get { return m_EnableCustomTheme; } get { return m_EnableCustomTheme; }