private void InitViewThemes() { ThemesDatabase.InitializeThemes(); bool renamedThemeData = false; foreach (ThemeData themeData in ThemesDatabase.Themes) { if (themeData == null) { continue; } if (themeData.name == ThemesDatabase.GetThemeDataFilename(themeData.ThemeName)) { continue; } AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(themeData), ThemesDatabase.GetThemeDataFilename(themeData.ThemeName)); themeData.SetDirty(false); renamedThemeData = true; } if (EditorPrefs.HasKey(DoozyWindowSettings.Instance.EditorPrefsKeyWindowCurrentTheme)) { m_currentThemeId = new Guid(EditorPrefs.GetString(DoozyWindowSettings.Instance.EditorPrefsKeyWindowCurrentTheme)); if (!ThemesDatabase.Contains(m_currentThemeId)) { CurrentThemeId = ThemesDatabase.GetThemeData(ThemesDatabase.GENERAL_THEME_NAME).Id; } } else { ThemeData generalTheme = ThemesDatabase.GetThemeData(ThemesDatabase.GENERAL_THEME_NAME); CurrentThemeId = generalTheme.Id; } if (renamedThemeData) { Save(); } }
private void DrawViewThemesHeader(ThemeData themeData) { GUILayout.BeginArea(ThemesHeaderAreaRect); { #region Theme Name GUILayout.Space(DGUI.Properties.Space(8) * CurrentViewExpanded.faded); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (EditMode.faded > 0.01f) { string themeName = themeData.ThemeName; GUI.enabled = !themeData.IsGeneralTheme; { EditorGUI.BeginChangeCheck(); themeName = EditorGUILayout.TextField(themeName); if (EditorGUI.EndChangeCheck()) { if (!ThemesDatabase.Contains(themeName) && !ThemesDatabase.Contains(themeName.Trim())) { themeData.UndoRecord(UILabels.UpdateValue); themeData.ThemeName = themeName; themeData.SetDirty(false); } } } GUI.enabled = true; } else { DGUI.Label.Draw(themeData.ThemeName, ThemeNameStyle, DGUI.Colors.DisabledTextColorName); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); if (EditMode.faded > 0.01f) { GUILayout.Space(3f); } GUILayout.Space(DGUI.Properties.Space(6) * CurrentViewExpanded.faded); #endregion #region Tabs - Color, Image, Sound... GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); var toolbarButtons = new List <DGUI.Toolbar.ToolbarButton> { ThemeColorTab, ThemeSpriteTab, ThemeTextureTab, ThemeFontTab }; #if dUI_TextMeshPro toolbarButtons.Add(ThemeFontAssetTab); #endif m_selectedThemeTab = DGUI.Toolbar.Draw(m_selectedThemeTab, toolbarButtons, DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(8)); } GUILayout.EndHorizontal(); if (EditMode.faded > 0.01f) { GUILayout.Space(-4f); } GUILayout.Space(DGUI.Properties.Space(8) * CurrentViewExpanded.faded); #endregion } GUILayout.EndArea(); }