Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
        }