private static void WarnAboutTwoColumnLayout()
 {
     if (RainbowFoldersEditorUtility.IsLastSelectedProjectViewInTwoColumnLayout())
     {
         Debug.LogWarning("Please remember to perform colorizing on the folder in the right column of the project view");
     }
 }
        public static void ApplyCustom()
        {
            var window   = RainbowFoldersPopup.GetDraggableWindow();
            var position = RainbowFoldersEditorUtility.GetProjectWindow().position.position + new Vector2(10f, 30f);
            var paths    = Selection.assetGUIDs.Select <string, string>(AssetDatabase.GUIDToAssetPath).Where(AssetDatabase.IsValidFolder).ToList();

            window.ShowWithParams(position, paths.ToList(), 0);
        }
Beispiel #3
0
        private static void DrawEditIcon(string guid, Rect rect)
        {
            if (!Event.current.alt)
            {
                _multiSelection = false;
                return;
            }

            var isSmall     = IsIconSmall(ref rect);
            var isMouseOver = rect.Contains(Event.current.mousePosition);

            _multiSelection = (IsSelected(guid)) ? isMouseOver || _multiSelection : !isMouseOver && _multiSelection;

            // if mouse is not over current folder icon or selected group
            if (!isMouseOver && (!IsSelected(guid) || !_multiSelection))
            {
                return;
            }

            var path = AssetDatabase.GUIDToAssetPath(guid);

            if (!AssetDatabase.IsValidFolder(path))
            {
                return;
            }

            var editIcon = RainbowFoldersEditorUtility.GetEditFolderIcon(isSmall);

            DrawCustomIcon(ref rect, editIcon, isSmall);

            if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
            {
                var window   = RainbowFoldersPopup.GetDraggableWindow();
                var position = GUIUtility.GUIToScreenPoint(rect.position + new Vector2(0, rect.height + 2));

                if (_multiSelection)
                {
                    var assetGUIDs = Selection.assetGUIDs;
                    var size       = assetGUIDs.Length;

                    var paths = new string[size];
                    for (var i = 0; i < size; i++)
                    {
                        paths[i] = AssetDatabase.GUIDToAssetPath(assetGUIDs[i]);
                    }
                    var index = ArrayUtility.IndexOf(paths, path);

                    window.ShowWithParams(position, paths, index);
                }
                else
                {
                    window.ShowWithParams(position, new[] { path }, 0);
                }
            }

            EditorApplication.RepaintProjectWindow();
        }
 static FolderColorsStorage()
 {
     LoadFromResources();
     if (instance != null)
     {
         return;
     }
     RainbowFoldersEditorUtility.CreateAsset <FolderColorsStorage>(RESOURCE_NAME, "Assets/Resources/Internal");
     LoadFromResources();
 }
Beispiel #5
0
        private void ButtonDefault(Rect rect)
        {
            var icon = RainbowFoldersEditorUtility.GetDeleteButtonIcon();

            if (!GUI.Button(rect, new GUIContent(icon, "Revert to Default"), GUIStyle.none))
            {
                return;
            }
            _currentFolder.SmallIcon = null;
            _currentFolder.LargeIcon = null;
        }
Beispiel #6
0
        private void ButtonPresets(Rect rect)
        {
            var icon = RainbowFoldersEditorUtility.GetPresetsButtonIcon();

            if (!GUI.Button(rect, new GUIContent(icon, "Presets"), GUIStyle.none))
            {
                return;
            }

            RainbowFoldersPresetsMenu.ShowDropDown(rect, _currentFolder);
        }
Beispiel #7
0
        //---------------------------------------------------------------------
        // Helpers
        //---------------------------------------------------------------------

        private void ButtonSettings(Rect rect)
        {
            var icon = RainbowFoldersEditorUtility.GetSettingsButtonIcon();

            if (!GUI.Button(rect, new GUIContent(icon, "Settings"), GUIStyle.none))
            {
                return;
            }
            Selection.activeObject = _settings;
            Close();
        }
        private static void DrawCustomIcon(string guid, Rect rect, Texture texture, bool isSmall)
        {
            if (rect.width > LARGE_ICON_SIZE)
            {
                // center the icon if it is zoomed
                var offset = (rect.width - LARGE_ICON_SIZE) / 2f;
                rect = new Rect(rect.x + offset, rect.y + offset, LARGE_ICON_SIZE, LARGE_ICON_SIZE);
            }
            else
            {
                // unity shifted small icons a bit in 5.5
#if UNITY_5_5
                if (isSmall)
                {
                    rect = new Rect(rect.x + 3, rect.y, rect.width, rect.height);
                }
#elif UNITY_5_6_OR_NEWER
                if (isSmall && !IsTreeView(rect))
                {
                    rect = new Rect(rect.x + 3, rect.y, rect.width, rect.height);
                }
#endif
            }

            if (_isCollabEnabled())
            {
                var background = RainbowFoldersEditorUtility.GetCollabBackground(isSmall, EditorGUIUtility.isProSkin);
                GUI.DrawTexture(rect, background);
                GUI.DrawTexture(rect, texture);

#if UNITY_2020_1_OR_NEWER
                _drawCollabOverlay(guid, rect, null);
#else
                _drawCollabOverlay(guid, rect);
#endif
            }
            else if (_isVcsEnabled())
            {
                var iconRect = (!isSmall) ? rect : new Rect(rect.x + 7, rect.y, rect.width, rect.height);
                GUI.DrawTexture(iconRect, texture);
#if UNITY_2020_1_OR_NEWER
                _drawCollabOverlay(guid, rect, null);
#else
                _drawCollabOverlay(guid, rect);
#endif
            }
            else
            {
                GUI.DrawTexture(rect, texture);
            }
        }
Beispiel #9
0
        //---------------------------------------------------------------------
        // Messages
        //---------------------------------------------------------------------

        public override void OnGUI()
        {
            base.OnGUI();

            // 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);

            // Content

            GUILayout.BeginHorizontal();
            {
                GUI.skin.label.wordWrap = true;
                GUILayout.Label(new GUIContent(RainbowFoldersEditorUtility.GetAssetLogo()));

                GUILayout.BeginVertical();
                {
                    GUILayout.Label("Welcome!", EditorStyles.boldLabel);
                    GUILayout.Label("With \"Rainbow Folders\" you can set custom icon for any folder in Unity project browser.");
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("• Just hold the Alt key and click on any folder icon.");
            GUILayout.Label("• Configuration dialogue will appear, and you'll be able to assign icons the for the corresponding folder, your own ones or chose from dozens of presets.");
            GUILayout.Label("• To revert the folder icon to the default, just Alt-click on it, then press the red cross button in configuration dialogue and apply changes.");
            GUILayout.Label("• You can also edit multiple folders at once, just select them all and Alt-click at one of their icons.\n");

            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("More Info", GUILayout.Width(100f)))
                {
                    Application.OpenURL(AssetInfo.HELP_URL);
                }
                ;
                if (GUILayout.Button("Close", GUILayout.Width(100f)))
                {
                    Close();
                }
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();
        }
Beispiel #10
0
        private static void DrawCustomIcon(string guid, Rect rect, Texture texture, bool isSmall)
        {
            var iconRect = rect;

            if (iconRect.width > LARGE_ICON_SIZE)
            {
                // center the icon if it is zoomed
                var offset = (iconRect.width - LARGE_ICON_SIZE) / 2f;
                iconRect = new Rect(iconRect.x + offset, iconRect.y + offset, LARGE_ICON_SIZE, LARGE_ICON_SIZE);
            }
            else
            {
                // unity shifted small icons a bit in 5.5
                #if UNITY_5_5
                if (isSmall)
                {
                    rect = iconRect = new Rect(iconRect.x + 3, iconRect.y, iconRect.width, iconRect.height);
                }
                #endif
            }

            if (_isCollabEnabled())
            {
                var background = RainbowFoldersEditorUtility.GetCollabBackground(isSmall, EditorGUIUtility.isProSkin);

                GUI.Box(rect, string.Empty, ItemBgStyle);
                GUI.DrawTexture(iconRect, background);
                GUI.DrawTexture(iconRect, texture);

                #if UNITY_2017_1_OR_NEWER
                _drawCollabOverlay(rect, guid, isSmall);
                #else
                _drawCollabOverlay(guid, rect);
                #endif
            }
            else if (_isVcsEnabled())
            {
                var background = RainbowFoldersEditorUtility.GetCollabBackground(isSmall, EditorGUIUtility.isProSkin);
                iconRect = (!isSmall) ? iconRect : new Rect(iconRect.x + 7, iconRect.y, iconRect.width, iconRect.height);

                GUI.Box(rect, string.Empty, ItemBgStyle);
                GUI.DrawTexture(iconRect, background);
                GUI.DrawTexture(iconRect, texture);
                _drawVcsOverlay(guid, rect, null);
            }
            else
            {
                GUI.DrawTexture(iconRect, texture);
            }
        }
Beispiel #11
0
        private void ButtonDefault(Rect rect)
        {
            var icon = RainbowFoldersEditorUtility.GetDeleteButtonIcon();

            if (!GUI.Button(rect, new GUIContent(icon, "Revert to Default"), GUIStyle.none))
            {
                return;
            }

            _currentFolder.SmallIcon       = null;
            _currentFolder.LargeIcon       = null;
            _currentFolder.IsIconRecursive = false;
            _currentFolder.IsIconCustom    = false;

            _currentFolder.Background            = null;
            _currentFolder.IsBackgroundRecursive = false;
            _currentFolder.IsBackgroundCustom    = false;
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var originalPosition = position;

            var folderType = property.FindPropertyRelative("Platform");
            var smallIcon  = property.FindPropertyRelative("SmallIcon");
            var largeIcon  = property.FindPropertyRelative("LargeIcon");

            // Labels

            position.y     += PADDING;
            position.width  = LABELS_WIDTH;
            position.height = LINE_HEIGHT;

            EditorGUI.LabelField(position, "Folder Color");
            position.y += LINE_HEIGHT;
            EditorGUI.LabelField(position, "Small Icon");
            position.y += LINE_HEIGHT;
            EditorGUI.LabelField(position, "Large Icon");

            // Values

            position.x    += LABELS_WIDTH;
            position.y     = originalPosition.y + PADDING;
            position.width = originalPosition.width - LABELS_WIDTH - PREVIEW_SIZE_LARGE - PADDING;

            EditorGUI.PropertyField(position, folderType, GUIContent.none);
            position.y += LINE_HEIGHT;
            EditorGUI.PropertyField(position, smallIcon, GUIContent.none);
            position.y += LINE_HEIGHT;
            EditorGUI.PropertyField(position, largeIcon, GUIContent.none);

            // Preview

            position.x    += position.width + PADDING;
            position.y     = originalPosition.y;
            position.width = position.height = PREVIEW_SIZE_LARGE;
            GUI.DrawTexture(position, (Texture2D)largeIcon.objectReferenceValue ?? RainbowFoldersEditorUtility.GetDefaultFolderIcon());

            position.y    += PREVIEW_SIZE_LARGE - PREVIEW_SIZE_SMALL - 4f;
            position.width = position.height = PREVIEW_SIZE_SMALL;
            GUI.DrawTexture(position, (Texture2D)smallIcon.objectReferenceValue ?? RainbowFoldersEditorUtility.GetDefaultFolderIcon());
        }
Beispiel #13
0
        private static void DrawEditIcon(string guid, Rect rect)
        {
            if ((Event.current.modifiers & RainbowFoldersPreferences.ModifierKey) == EventModifiers.None ||
                (Event.current.modifiers & EventModifiers.Control) == EventModifiers.None)
            {
                _multiSelection = false;
                return;
            }

            var isSmall     = IsIconSmall(rect);
            var iconRect    = GetIconRect(rect, isSmall);
            var isMouseOver = rect.Contains(Event.current.mousePosition);

            _multiSelection = (IsSelected(guid)) ? isMouseOver || _multiSelection : !isMouseOver && _multiSelection;

            // if mouse is not over current folder icon or selected group
            if (!isMouseOver && (!IsSelected(guid) || !_multiSelection))
            {
                return;
            }

            var path = AssetDatabase.GUIDToAssetPath(guid);

            if (!AssetDatabase.IsValidFolder(path))
            {
                return;
            }

            var editIcon = RainbowFoldersEditorUtility.GetEditFolderIcon(isSmall, EditorGUIUtility.isProSkin);

            DrawCustomIcon(guid, iconRect, editIcon, isSmall);

            if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
            {
                ShowPopupWindow(iconRect, path);
            }

            EditorApplication.RepaintProjectWindow();
        }
Beispiel #14
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.Length == 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);
        }
Beispiel #15
0
        //---------------------------------------------------------------------
        // Helpers
        //---------------------------------------------------------------------

        private static Vector2 CalcWindowPosition()
        {
            return(RainbowFoldersEditorUtility.GetProjectWindow().position.position + new Vector2(10f, 30f));
        }
Beispiel #16
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);
        }