diff --git a/Editor/ChildComponents/ThemeDrawer.cs b/Editor/ChildComponents/ThemeDrawer.cs index 6c443f2a..f5743e3e 100644 --- a/Editor/ChildComponents/ThemeDrawer.cs +++ b/Editor/ChildComponents/ThemeDrawer.cs @@ -44,6 +44,7 @@ namespace XCharts.Editor XCThemeMgr.SwitchTheme(chart, chartNameList[selectedIndex]); } PropertyField(prop, "m_SharedTheme"); + PropertyField(prop, "m_TransparentBackground"); PropertyField(prop, "m_EnableCustomTheme"); using (new EditorGUI.DisabledScope(!prop.FindPropertyRelative("m_EnableCustomTheme").boolValue)) { diff --git a/Editor/Windows/XChartsEditor.cs b/Editor/Windows/XChartsEditor.cs index daf7d762..01b638bf 100644 --- a/Editor/Windows/XChartsEditor.cs +++ b/Editor/Windows/XChartsEditor.cs @@ -193,20 +193,5 @@ namespace XCharts.Editor XChartsMgr.ModifyTMPRefence(true); XChartsMgr.DisableTextMeshPro(); } - - [MenuItem("XCharts/Theme/Export Default Theme")] - public static void ExportDefaultTheme() - { - var profile = ScriptableObject.CreateInstance(); - 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(); - } } } \ No newline at end of file diff --git a/Runtime/Theme/ThemeStyle.cs b/Runtime/Theme/ThemeStyle.cs index 0b8dce84..394e3af9 100644 --- a/Runtime/Theme/ThemeStyle.cs +++ b/Runtime/Theme/ThemeStyle.cs @@ -41,7 +41,8 @@ namespace XCharts.Runtime { [SerializeField] private bool m_Show = true; [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 Color32 m_CustomBackgroundColor; #if UNITY_2020_2 @@ -83,8 +84,27 @@ namespace XCharts.Runtime /// 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; + } } + /// + /// Whether the background color is transparent. When true, the background color is not drawn. + /// |是否透明背景颜色。当设置为true时,不绘制背景颜色。 + /// + public bool transparentBackground + { + get { return m_TransparentBackground; } + set { m_TransparentBackground = value; SetAllDirty(); } + } + /// + /// 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’同步主题的颜色到自定义颜色。也可以手动设置。 + /// + /// public bool enableCustomTheme { get { return m_EnableCustomTheme; }