コード例 #1
0
        private ThemeVariantData DrawThemeVariantButton(ThemeData themeData, ThemeVariantData variant)
        {
            ThemeVariantData deleteVariant = null;

            if (EditMode.faded > 0.01f)
            {
                string variantName = variant.VariantName;
                GUILayout.BeginHorizontal(GUILayout.Width(m_themeVariantColumnWidth));
                {
                    GUILayout.Space(DGUI.Properties.Space(1 - EditMode.faded));

                    if (DGUI.Button.IconButton.Minus())
                    {
                        deleteVariant = variant;
                    }

                    GUILayout.Space(DGUI.Properties.Space(2 * (1 - EditMode.faded)));

                    EditorGUI.BeginChangeCheck();
                    variantName = EditorGUILayout.TextField(variantName);
                }
                GUILayout.EndHorizontal();
                if (EditorGUI.EndChangeCheck())
                {
                    themeData.UndoRecord(UILabels.UpdateValue);
                    variant.VariantName = variantName;
                    themeData.SetDirty(false);
                }
            }
            else
            {
                bool activeVariant = themeData.ActiveVariant.Id.Equals(variant.Id);
                if (DGUI.Button.Draw(variant.VariantName,
                                     activeVariant ? CurrentViewColorName : DGUI.Colors.DisabledBackgroundColorName,
                                     activeVariant ? CurrentViewColorName : DGUI.Colors.DisabledTextColorName,
                                     activeVariant,
                                     m_themeVariantButtonHeight,
                                     m_themeVariantColumnWidth))
                {
                    themeData.ActivateVariant(variant);
                    themeData.SetDirty(false);
                    UpdateAllThemeTargets(themeData);
                }
            }


            if (EditMode.faded > 0.01f)
            {
                GUILayout.Space(DGUI.Properties.Space(2));
            }
            GUILayout.Space(DGUI.Properties.Space(4));
            DrawHorizontalDivider();
            GUILayout.Space(DGUI.Properties.Space());

            return(deleteVariant);
        }
コード例 #2
0
        private ThemeVariantData DrawViewThemesViewVariantsSprite(ThemeData themeData)
        {
            ThemeVariantData deleteVariant = null;
            float            rowHeight     = GetThemePropertyRowHeight(m_selectedThemeTab) - DGUI.Properties.Space(5);

            GUILayout.BeginHorizontal();
            {
                foreach (ThemeVariantData variant in themeData.Variants.Where(variant => variant != null))
                {
                    GUILayout.BeginVertical(GUILayout.Width(m_themeVariantColumnWidth),
                                            GUILayout.Height(rowHeight));
                    {
                        deleteVariant = DrawThemeVariantButton(themeData, variant);
                        if (deleteVariant != null)
                        {
                            GUILayout.EndVertical();
                            break;
                        }

                        for (int propertyIndex = 0; propertyIndex < themeData.SpriteLabels.Count; propertyIndex++)
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(m_themeVariantColumnWidth));
                            {
                                GUILayout.FlexibleSpace();
                                EditorGUI.BeginChangeCheck();
                                var sprite = (Sprite)EditorGUILayout.ObjectField(GUIContent.none, variant.Sprites[propertyIndex].Sprite, typeof(Sprite), false,
                                                                                 GUILayout.Width(rowHeight),
                                                                                 GUILayout.Height(rowHeight));
                                if (EditorGUI.EndChangeCheck())
                                {
                                    themeData.UndoRecord(UILabels.UpdateValue);
                                    variant.Sprites[propertyIndex] = new SpriteId(variant.Sprites[propertyIndex].Id, sprite);
                                    themeData.SetDirty(false);
                                    UpdateAllThemeTargets(themeData);
                                }

                                GUILayout.FlexibleSpace();
                            }
                            GUILayout.EndHorizontal();

                            GUILayout.FlexibleSpace();
                            GUILayout.Space(DGUI.Properties.Space());
                            DrawHorizontalDivider();
                            GUILayout.Space(DGUI.Properties.Space());
                        }
                    }
                    GUILayout.EndVertical();
                }

                DrawThemeAddVariantButton(themeData);

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            return(deleteVariant);
        }
コード例 #3
0
        private ThemeVariantData DrawViewThemesViewVariantsFontAsset(ThemeData themeData)
        {
            ThemeVariantData deleteVariant = null;

            GUILayout.BeginHorizontal();
            {
                foreach (ThemeVariantData variant in themeData.Variants.Where(variant => variant != null))
                {
                    GUILayout.BeginVertical(GUILayout.Width(m_themeVariantColumnWidth));
                    {
                        deleteVariant = DrawThemeVariantButton(themeData, variant);
                        if (deleteVariant != null)
                        {
                            GUILayout.EndVertical();
                            break;
                        }

                        for (int propertyIndex = 0; propertyIndex < themeData.FontAssetLabels.Count; propertyIndex++)
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(m_themeVariantColumnWidth));
                            {
#if dUI_TextMeshPro
                                GUILayout.FlexibleSpace();
                                EditorGUI.BeginChangeCheck();
                                var fontAsset = (TMP_FontAsset)EditorGUILayout.ObjectField(GUIContent.none, variant.FontAssets[propertyIndex].FontAsset, typeof(TMP_FontAsset), false, GUILayout.Width(m_themeVariantColumnWidth));
                                if (EditorGUI.EndChangeCheck())
                                {
                                    themeData.UndoRecord(UILabels.UpdateValue);
                                    variant.FontAssets[propertyIndex] = new FontAssetId(variant.FontAssets[propertyIndex].Id, fontAsset);
                                    themeData.SetDirty(false);
                                    UpdateAllThemeTargets(themeData);
                                }

                                GUILayout.FlexibleSpace();
#endif
                            }
                            GUILayout.EndHorizontal();

                            GUILayout.Space(DGUI.Properties.Space());
                            DrawHorizontalDivider();
                            GUILayout.Space(DGUI.Properties.Space());
                        }
                    }
                    GUILayout.EndVertical();
                }

                DrawThemeAddVariantButton(themeData);

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            return(deleteVariant);
        }
コード例 #4
0
        private ThemeVariantData DrawViewThemesViewVariantsColor(ThemeData themeData)
        {
            ThemeVariantData deleteVariant = null;

            GUILayout.BeginHorizontal();
            {
                foreach (ThemeVariantData variant in themeData.Variants.Where(variant => variant != null))
                {
                    GUILayout.BeginVertical(GUILayout.Width(m_themeVariantColumnWidth));
                    {
                        deleteVariant = DrawThemeVariantButton(themeData, variant);
                        if (deleteVariant != null)
                        {
                            GUILayout.EndVertical();
                            break;
                        }

                        for (int propertyIndex = 0; propertyIndex < themeData.ColorLabels.Count; propertyIndex++)
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(m_themeVariantColumnWidth));
                            {
                                GUILayout.FlexibleSpace();
                                EditorGUI.BeginChangeCheck();
                                Color color = EditorGUILayout.ColorField(GUIContent.none, variant.Colors[propertyIndex].Color, GUILayout.Width(DGUI.Properties.DefaultFieldWidth));
                                if (EditorGUI.EndChangeCheck())
                                {
                                    themeData.UndoRecord(UILabels.UpdateValue);
                                    variant.Colors[propertyIndex] = new ColorId(variant.Colors[propertyIndex].Id, color);
                                    themeData.SetDirty(false);
                                    UpdateAllThemeTargets(themeData);
                                }

                                GUILayout.FlexibleSpace();
                            }
                            GUILayout.EndHorizontal();

                            GUILayout.Space(DGUI.Properties.Space());
                            DrawHorizontalDivider();
                            GUILayout.Space(DGUI.Properties.Space());
                        }
                    }
                    GUILayout.EndVertical();
                }

                DrawThemeAddVariantButton(themeData);

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            return(deleteVariant);
        }
コード例 #5
0
        private void DrawViewThemesViewProperties(ThemeData themeData, int selectedThemeTabIndex)
        {
#if !dUI_TextMeshPro
            if (selectedThemeTabIndex == FONT_ASSET_TAB_INDEX)
            {
                selectedThemeTabIndex = COLOR_TAB_INDEX;
                return;
            }
#endif

            Guid           deleteGuid              = Guid.Empty;
            List <LabelId> propertyList            = new List <LabelId>();
            string         addPropertyButtonName   = "+";
            Action         addPropertyButtonAction = () => { };

            switch (selectedThemeTabIndex)
            {
            case COLOR_TAB_INDEX:
                propertyList            = themeData.ColorLabels;
                addPropertyButtonName   = UILabels.NewColor;
                addPropertyButtonAction = () => { themeData.AddColorProperty(true); };
                break;

            case SPRITE_TAB_INDEX:
                propertyList            = themeData.SpriteLabels;
                addPropertyButtonName   = UILabels.NewSprite;
                addPropertyButtonAction = () => { themeData.AddSpriteProperty(true); };
                break;

            case TEXTURE_TAB_INDEX:
                propertyList            = themeData.TextureLabels;
                addPropertyButtonName   = UILabels.NewTexture;
                addPropertyButtonAction = () => { themeData.AddTextureProperty(true); };
                break;

            case FONT_TAB_INDEX:
                propertyList            = themeData.FontLabels;
                addPropertyButtonName   = UILabels.NewFont;
                addPropertyButtonAction = () => { themeData.AddFontProperty(true); };
                break;

#if dUI_TextMeshPro
            case FONT_ASSET_TAB_INDEX:
                propertyList            = themeData.FontAssetLabels;
                addPropertyButtonName   = UILabels.NewFontAsset;
                addPropertyButtonAction = () => { themeData.AddFontAssetProperty(true); };
                break;
#endif
            }


            GUILayout.Space(DGUI.Properties.Space(2));
            DrawHorizontalDivider();
            GUILayout.Space(DGUI.Properties.Space());

            for (int propertyIndex = 0; propertyIndex < propertyList.Count; propertyIndex++)
            {
                GUILayout.BeginVertical(GUILayout.Height(GetThemePropertyRowHeight(selectedThemeTabIndex)));
                {
                    GUILayout.FlexibleSpace();

                    GUILayout.BeginHorizontal(GUILayout.Width(m_themePropertyColumnWidth));
                    {
                        if (EditMode.faded > 0.01f)
                        {
                            GUILayout.Space(DGUI.Properties.Space(1 - EditMode.faded));

                            if (DGUI.Button.IconButton.Minus())
                            {
                                deleteGuid = propertyList[propertyIndex].Id;
                            }

                            GUILayout.Space(DGUI.Properties.Space(2 * (1 - EditMode.faded)));

                            EditorGUI.BeginChangeCheck();
                            string label = EditorGUILayout.TextField(propertyList[propertyIndex].Label,
                                                                     GUILayout.Width(m_themePropertyColumnWidth - DGUI.Properties.Space(4) - DGUI.Sizes.ICON_BUTTON_SIZE));
                            if (EditorGUI.EndChangeCheck())
                            {
                                themeData.UndoRecord(UILabels.UpdateValue);
                                propertyList[propertyIndex] = new LabelId(propertyList[propertyIndex].Id, label);
                                themeData.SetDirty(false);
                            }
                        }
                        else
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(m_themePropertyColumnWidth));
                            {
                                GUILayout.Space(DGUI.Properties.Space(2));
                                DGUI.Label.Draw(propertyList[propertyIndex].Label, Size.L, TextAlign.Left, DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(2));
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.FlexibleSpace();
                    GUILayout.Space(DGUI.Properties.Space());
                    DrawHorizontalDivider();
                    GUILayout.Space(DGUI.Properties.Space());
                }
                GUILayout.EndVertical();
            }

            DrawAddPropertyButton(addPropertyButtonName, addPropertyButtonAction);

            if (deleteGuid == Guid.Empty)
            {
                return;
            }
            switch (selectedThemeTabIndex)
            {
            case COLOR_TAB_INDEX:
                themeData.RemoveColorProperty(deleteGuid, true, false);
                break;

            case SPRITE_TAB_INDEX:
                themeData.RemoveSpriteProperty(deleteGuid, true, false);
                break;

            case TEXTURE_TAB_INDEX:
                themeData.RemoveTextureProperty(deleteGuid, true, false);
                break;

            case FONT_TAB_INDEX:
                themeData.RemoveFontProperty(deleteGuid, true, false);
                break;

#if dUI_TextMeshPro
            case FONT_ASSET_TAB_INDEX:
                themeData.RemoveFontAssetProperty(deleteGuid, true, false);
                break;
#endif
            }
        }
コード例 #6
0
        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();
        }