コード例 #1
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
            }
        }