Exemple #1
0
        //---------------------------------------------------------------------
        // Messages
        //---------------------------------------------------------------------

        public override void OnGUI()
        {
            base.OnGUI();
            ChangeWindowSize(_currentFolder.IsIconCustom, _currentFolder.IsBackgroundCustom);
            var rect = _windowRect;

            // Background

            var borderColor = EditorGUIUtility.isProSkin ? new Color(0.13f, 0.13f, 0.13f) : new Color(0.51f, 0.51f, 0.51f);

            EditorGUI.DrawRect(_windowRect, borderColor);

            var backgroundColor = EditorGUIUtility.isProSkin ? new Color(0.18f, 0.18f, 0.18f) : new Color(0.83f, 0.83f, 0.83f);

            EditorGUI.DrawRect(_backgroundRect, backgroundColor);

            // Labels

            rect.x     += 0.5f * PADDING;
            rect.y     += PADDING;
            rect.width  = LABELS_WIDTH - PADDING;
            rect.height = LINE_HEIGHT;

            _currentFolder.Type = (KeyType)EditorGUI.EnumPopup(rect, _currentFolder.Type);

            rect.y += LINE_HEIGHT + 6f;
            EditorGUI.LabelField(rect, "Icon");

            if (_currentFolder.IsIconCustom)
            {
                rect.y += LINE_HEIGHT + 4f;
                EditorGUI.LabelField(rect, "x16", EditorStyles.miniLabel);
                rect.y += LINE_HEIGHT + 2f;
                EditorGUI.LabelField(rect, "x64", EditorStyles.miniLabel);
            }

            rect.y += LINE_HEIGHT + 2f;
            EditorGUI.LabelField(rect, "Recursive", EditorStyles.miniLabel);

            rect.y += LINE_HEIGHT + SPACING * 6f;
            EditorGUI.LabelField(rect, "Background");

            if (_currentFolder.IsBackgroundCustom)
            {
                rect.y += LINE_HEIGHT + 4f;
                EditorGUI.LabelField(rect, "x16", EditorStyles.miniLabel);
            }

            rect.y += LINE_HEIGHT + 2f;
            EditorGUI.LabelField(rect, "Recursive", EditorStyles.miniLabel);

            // Values

            rect.x    += LABELS_WIDTH;
            rect.y     = _windowRect.y + PADDING;
            rect.width = _windowRect.width - LABELS_WIDTH - PADDING;

            GUI.enabled = false;
            if (_paths.Count == 1)
            {
                _currentFolder.Key = (_currentFolder.Type == KeyType.Path) ? _paths[0] : Path.GetFileName(_paths[0]);
            }
            else
            {
                _currentFolder.Key = "---";
            }
            EditorGUI.TextField(rect, GUIContent.none, _currentFolder.Key);
            GUI.enabled = true;


            rect.width -= PREVIEW_SIZE_LARGE + PADDING;
            rect.y     += LINE_HEIGHT + SPACING * 4f + SPACING;
            DrawIconPopupMenu(rect, _currentFolder);

            if (_currentFolder.IsIconCustom)
            {
                rect.y += LINE_HEIGHT + 4f + SPACING;
                _currentFolder.SmallIcon = (Texture2D)EditorGUI.ObjectField(rect, _currentFolder.SmallIcon, typeof(Texture2D), false);

                rect.y += LINE_HEIGHT + SPACING;
                _currentFolder.LargeIcon = (Texture2D)EditorGUI.ObjectField(rect, _currentFolder.LargeIcon, typeof(Texture2D), false);
            }

            rect.y += LINE_HEIGHT + 2f;
            _currentFolder.IsIconRecursive = EditorGUI.Toggle(rect, _currentFolder.IsIconRecursive);


            rect.y += LINE_HEIGHT + SPACING * 6f;
            DrawBackgroundPopupMenu(rect, _currentFolder);

            if (_currentFolder.IsBackgroundCustom)
            {
                rect.y += LINE_HEIGHT + 4f + SPACING;
                _currentFolder.Background = (Texture2D)EditorGUI.ObjectField(rect, _currentFolder.Background, typeof(Texture2D), false);
            }

            rect.y += LINE_HEIGHT + 2f;
            _currentFolder.IsBackgroundRecursive = EditorGUI.Toggle(rect, _currentFolder.IsBackgroundRecursive);

            // Preview

            rect.x    += rect.width + PADDING;
            rect.y     = _windowRect.y + LINE_HEIGHT + 4f;
            rect.width = rect.height = PREVIEW_SIZE_LARGE;
            GUI.DrawTexture(rect, RainbowFoldersEditorUtility.GetDefaultFolderIcon());
            if (_currentFolder.LargeIcon)
            {
                GUI.DrawTexture(rect, _currentFolder.LargeIcon);
            }

            rect.y    += PREVIEW_SIZE_LARGE - PREVIEW_SIZE_SMALL - 4f;
            rect.width = rect.height = PREVIEW_SIZE_SMALL;
            GUI.DrawTexture(rect, RainbowFoldersEditorUtility.GetDefaultFolderIcon());
            if (_currentFolder.SmallIcon)
            {
                GUI.DrawTexture(rect, _currentFolder.SmallIcon);
            }

            rect.y    += LINE_HEIGHT + SPACING * 3f;
            rect.width = PREVIEW_SIZE_LARGE;
            if (_currentFolder.Background != null)
            {
                GUI.DrawTexture(rect, _currentFolder.Background);
            }
            rect.x += 13f;
            EditorGUI.LabelField(rect, "Folder");

            // Buttons

            rect.x     = PADDING;
            rect.y     = position.height - LINE_HEIGHT - 0.75f * PADDING;
            rect.width = BUTTON_WIDTH_SMALL;
            ButtonSettings(rect);

            rect.x += BUTTON_WIDTH_SMALL + 0.75f * PADDING;
            ButtonDefault(rect);

            rect.x     = WINDOW_WIDTH - 2f * (BUTTON_WIDTH + PADDING);
            rect.width = BUTTON_WIDTH;
            ButtonCancel(rect);

            rect.x = WINDOW_WIDTH - BUTTON_WIDTH - PADDING;
            ButtonApply(rect);
        }
Exemple #2
0
        //---------------------------------------------------------------------
        // Messages
        //---------------------------------------------------------------------

        public override void OnGUI()
        {
            base.OnGUI();
            var rect = WINDOW_RECT;

            // Background

            var borderColor = EditorGUIUtility.isProSkin ? new Color(0.13f, 0.13f, 0.13f) : new Color(0.51f, 0.51f, 0.51f);

            EditorGUI.DrawRect(WINDOW_RECT, borderColor);

            var backgroundColor = EditorGUIUtility.isProSkin ? new Color(0.18f, 0.18f, 0.18f) : new Color(0.83f, 0.83f, 0.83f);

            EditorGUI.DrawRect(BACKGROUND_RECT, backgroundColor);

            // Labels

            rect.x     += 0.5f * PADDING;
            rect.y     += PADDING;
            rect.width  = LABELS_WIDTH - PADDING;
            rect.height = LINE_HEIGHT;

            _currentFolder.Type = (KeyType)EditorGUI.EnumPopup(rect, _currentFolder.Type);

            rect.y += LINE_HEIGHT + SPACING;
            EditorGUI.LabelField(rect, "Small Icon");
            rect.y += LINE_HEIGHT + SPACING;
            EditorGUI.LabelField(rect, "Large Icon");

            // Values

            rect.x    += LABELS_WIDTH;
            rect.y     = WINDOW_RECT.y + PADDING;
            rect.width = WINDOW_RECT.width - LABELS_WIDTH - PREVIEW_SIZE_LARGE - 2f * PADDING;

            GUI.enabled = false;
            if (_paths.Count == 1)
            {
                _currentFolder.Key = (_currentFolder.Type == KeyType.Path) ? _paths[0] : Path.GetFileName(_paths[0]);
            }
            else
            {
                _currentFolder.Key = "---";
            }
            EditorGUI.TextField(rect, GUIContent.none, _currentFolder.Key);
            GUI.enabled = true;

            rect.y += LINE_HEIGHT + SPACING;
            _currentFolder.SmallIcon = (Texture2D)EditorGUI.ObjectField(rect, _currentFolder.SmallIcon, typeof(Texture2D), false);
            rect.y += LINE_HEIGHT + SPACING;
            _currentFolder.LargeIcon = (Texture2D)EditorGUI.ObjectField(rect, _currentFolder.LargeIcon, typeof(Texture2D), false);

            // Preview

            rect.x    += rect.width + PADDING;
            rect.y     = WINDOW_RECT.y;
            rect.width = rect.height = PREVIEW_SIZE_LARGE;
            GUI.DrawTexture(rect, RainbowFoldersEditorUtility.GetDefaultFolderIcon());
            if (_currentFolder.LargeIcon)
            {
                GUI.DrawTexture(rect, _currentFolder.LargeIcon);
            }

            rect.y    += PREVIEW_SIZE_LARGE - PREVIEW_SIZE_SMALL - 4f;
            rect.width = rect.height = PREVIEW_SIZE_SMALL;
            GUI.DrawTexture(rect, RainbowFoldersEditorUtility.GetDefaultFolderIcon());
            if (_currentFolder.SmallIcon)
            {
                GUI.DrawTexture(rect, _currentFolder.SmallIcon);
            }

            // Buttons

            rect.x     = PADDING;
            rect.y     = WINDOW_HEIGHT - LINE_HEIGHT - 0.75f * PADDING;
            rect.width = BUTTON_WIDTH_SMALL;
            ButtonSettings(rect);

            rect.x += BUTTON_WIDTH_SMALL + 0.75f * PADDING;
            ButtonPresets(rect);

            rect.x += BUTTON_WIDTH_SMALL + 0.75f * PADDING;
            ButtonDefault(rect);

            rect.x     = WINDOW_WIDTH - 2f * (BUTTON_WIDTH + PADDING);
            rect.width = BUTTON_WIDTH;
            ButtonCancel(rect);

            rect.x = WINDOW_WIDTH - BUTTON_WIDTH - PADDING;
            ButtonApply(rect);
        }