private void LoadElement(ThemeElementData data, Theme.ColorMode colorMode) { if (data != null) { elementImage.sprite = data.GetElementSprite(); elementImage.type = data.GetSpriteType(); elementImage.color = data.GetColorByMode(colorMode); } }
public override void LoadElement(Theme theme, Theme.ColorMode colorMode) { ThemeElementData data = theme.generalUIThemeDictionary.GetElementData(toggled ? secondaryKey : primaryKey); if (data != null) { elementImage.sprite = data.GetElementSprite(); elementImage.type = data.GetSpriteType(); elementImage.color = data.GetColorByMode(colorMode); } }
public override void LoadElement(Theme theme, Theme.ColorMode colorMode) { ThemeElementData data = theme.gameUIThemeDictionary.GetElementData(currentKey); if (data != null) { elementImage.sprite = data.GetElementSprite(); elementImage.type = data.GetSpriteType(); elementImage.color = data.GetColorByMode(colorMode); } }
public override void LoadElement(Theme theme, Theme.ColorMode colorMode) { if (theme != null) { ThemeElementData data = theme.generalUIThemeDictionary.GetElementData(highlighted ? highlightKey : normalKey); if (data != null) { targetImage.sprite = data.GetElementSprite(); targetImage.color = data.GetColorByMode(colorMode); } } }
public void SetValue(int index, ThemeElementData newData) { if (values.Count - 1 > index || index < 0) { return; } ThemeElementData currentData = values[index]; currentData.SetColorDictionary(newData.GetDictionary()); currentData.SetSprite(newData.GetElementSprite()); }
private void DrawThemeData(string dataTitle, ThemeElementData data) { EditorGUILayout.LabelField($"{dataTitle} Data", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); data.SetSprite((Sprite)EditorGUILayout.ObjectField(data.GetElementSprite(), typeof(Sprite), false, GUILayout.MaxWidth(200f))); data.SetSpriteType((Image.Type)EditorGUILayout.EnumPopup(data.GetSpriteType())); EditorGUILayout.EndHorizontal(); ColorDictionary dictionary = data.GetDictionary(); DrawColorDictionary(dictionary); }
public void Add(Theme.GeneralUIThemeKey key, ThemeElementData value) { if (keys == null || values == null) { keys = new List <Theme.GeneralUIThemeKey>(); values = new List <ThemeElementData>(); keys.Add(key); values.Add(value); return; } if (!Contains(key, out int index)) { keys.Add(key); values.Add(value); } return; }
private void StoreThemeElements(Theme theme, Theme.ColorMode colorMode) { primaryKeyData = theme.generalUIThemeDictionary.GetElementData(primaryKey); secondaryKeyData = theme.generalUIThemeDictionary.GetElementData(secondaryKey); }
private void OnGUI() { #region Heading GUIStyle editorHeader = new GUIStyle(); editorHeader.fontSize = 24; editorHeader.fontStyle = FontStyle.Bold; editorHeader.normal.textColor = Color.black; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Theme Editor", editorHeader, GUILayout.MaxWidth(250f)); if (!creatingTheme) { if (GUILayout.Button("Toggle Active Theme", GUILayout.MaxWidth(250f))) { GenericMenu themeSelector = new GenericMenu(); Theme[] createdThemes = Resources.LoadAll <Theme>(themeFolderPath); if (createdThemes != null && createdThemes.Length > 0) { for (int i = 0; i < createdThemes.Length; i++) { themeSelector.AddItem(new GUIContent($"{createdThemes[i].name}"), false, ToggleActiveTheme, createdThemes[i]); } } themeSelector.AddSeparator(""); themeSelector.AddItem(new GUIContent("Create a new Theme"), false, BeginCreatingNewTheme); themeSelector.ShowAsContext(); } } EditorGUILayout.EndHorizontal(); #endregion #region Theme Creation Panel if (creatingTheme) { DrawThemeCreatePanel(); return; } #endregion #region Theme Editor EditorGUILayout.Separator(); if (currentTheme == null) { EditorGUILayout.LabelField("Please Select a theme to begin editing", EditorStyles.centeredGreyMiniLabel); return; } EditorGUILayout.Separator(); EditorGUILayout.LabelField($"Editing {currentTheme.name} Theme", EditorStyles.boldLabel); EditorGUILayout.Separator(); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); #region Background Section if (viewingBackgroundSection = EditorGUILayout.BeginFoldoutHeaderGroup(viewingBackgroundSection, "Background")) { DrawColorDictionary(currentTheme.background); EditorGUILayout.Separator(); } EditorGUILayout.EndFoldoutHeaderGroup(); #endregion #region General UI Section if (viewingGeneralUISection = EditorGUILayout.BeginFoldoutHeaderGroup(viewingGeneralUISection, "General UI Section")) { int generalUIKeyCount = Enum.GetNames(typeof(Theme.GeneralUIThemeKey)).Length; Theme.GeneralUIThemeKey currentKey; ThemeElementData data; for (int i = 0; i < generalUIKeyCount; i++) { currentKey = (Theme.GeneralUIThemeKey)i; if (!currentTheme.generalUIThemeDictionary.Contains(currentKey, out int index)) { data = new ThemeElementData(); currentTheme.generalUIThemeDictionary.Add(currentKey, data); } else { data = currentTheme.generalUIThemeDictionary.GetElementData(index); } DrawThemeData($"{currentKey}", data); EditorGUILayout.Separator(); } } EditorGUILayout.EndFoldoutHeaderGroup(); #endregion #region GameShape Section if (viewingGameShapeSection = EditorGUILayout.BeginFoldoutHeaderGroup(viewingGameShapeSection, "Game Shape Section")) { int shapeTypeCount = Enum.GetNames(typeof(GameShape.ShapeType)).Length; GameShape.ShapeType shapeType; for (int i = 0; i < shapeTypeCount; i++) { shapeType = (GameShape.ShapeType)i; if (!currentTheme.gameShapeThemeDictionary.Contains(shapeType, out int index)) { currentTheme.gameShapeThemeDictionary.Add(shapeType, null); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField($"{shapeType} Sprite", GUILayout.MaxWidth(150f)); currentTheme.gameShapeThemeDictionary.SetValue(i, (Sprite)EditorGUILayout.ObjectField(currentTheme.gameShapeThemeDictionary.GetElementData(shapeType), typeof(Sprite), false, GUILayout.MaxWidth(150f))); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Separator(); int colorTypeCount = Enum.GetNames(typeof(GameShape.ColorType)).Length; GameShape.ColorType colorType; for (int i = 0; i < shapeTypeCount; i++) { colorType = (GameShape.ColorType)i; if (!currentTheme.gameShapeThemeDictionary.Contains(colorType, out int index)) { currentTheme.gameShapeThemeDictionary.Add(colorType, new ColorDictionary()); } EditorGUILayout.LabelField($"{colorType} Color", EditorStyles.boldLabel, GUILayout.MaxWidth(150f)); DrawColorDictionary(currentTheme.gameShapeThemeDictionary.GetElementData(colorType)); } } EditorGUILayout.EndFoldoutHeaderGroup(); #endregion #region Game UI Section if (viewingGameUISection = EditorGUILayout.BeginFoldoutHeaderGroup(viewingGameUISection, "Game UI Section")) { int gameUIKeyCount = Enum.GetNames(typeof(Theme.GameUIThemeKey)).Length; Theme.GameUIThemeKey currentKey; ThemeElementData data; for (int i = 0; i < gameUIKeyCount; i++) { currentKey = (Theme.GameUIThemeKey)i; if (!currentTheme.gameUIThemeDictionary.Contains(currentKey, out int index)) { data = new ThemeElementData(); currentTheme.gameUIThemeDictionary.Add(currentKey, data); } else { data = currentTheme.gameUIThemeDictionary.GetElementData(index); } DrawThemeData($"{currentKey}", data); EditorGUILayout.Separator(); } } EditorGUILayout.EndFoldoutHeaderGroup(); #endregion #region Game Text Section if (viewingGameTextSection = EditorGUILayout.BeginFoldoutHeaderGroup(viewingGameTextSection, "Game Text Section")) { int textLabelCount = Enum.GetNames(typeof(Theme.TextUIThemeKey)).Length; Theme.TextUIThemeKey currentKey; for (int i = 0; i < textLabelCount; i++) { currentKey = (Theme.TextUIThemeKey)i; if (!currentTheme.textElementDictionary.Contains(currentKey, out int index)) { currentTheme.textElementDictionary.Add(currentKey, new ColorDictionary()); } EditorGUILayout.LabelField($"{currentKey} Colors", EditorStyles.boldLabel, GUILayout.MaxWidth(150f)); DrawColorDictionary(currentTheme.textElementDictionary.GetElementData(currentKey)); EditorGUILayout.Separator(); } } EditorGUILayout.EndFoldoutHeaderGroup(); #endregion EditorGUILayout.EndScrollView(); if (GUI.changed) { EditorUtility.SetDirty(currentTheme); } #endregion }