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); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var originalPosition = position; var folderKey = property.FindPropertyRelative("Key"); var folderKeyType = property.FindPropertyRelative("Type"); var folderRecursive = property.FindPropertyRelative("IsRecursive"); var smallIcon = property.FindPropertyRelative("SmallIcon"); var largeIcon = property.FindPropertyRelative("LargeIcon"); // Labels position.y += PADDING; position.width = LABELS_WIDTH - PADDING; position.height = LINE_HEIGHT; var typeSelected = (KeyType)Enum.GetValues(typeof(KeyType)).GetValue(folderKeyType.enumValueIndex); folderKeyType.enumValueIndex = (int)(KeyType)EditorGUI.EnumPopup(position, typeSelected); position.y += LINE_HEIGHT + SPACING; EditorGUI.LabelField(position, "Recursive"); position.y += LINE_HEIGHT + SPACING; EditorGUI.LabelField(position, "Small Icon"); position.y += LINE_HEIGHT + SPACING; EditorGUI.LabelField(position, "Large Icon"); // Values position.x += LABELS_WIDTH; position.y = originalPosition.y + PADDING; position.width = originalPosition.width - LABELS_WIDTH; EditorGUI.PropertyField(position, folderKey, GUIContent.none); position.width = originalPosition.width - LABELS_WIDTH - PREVIEW_SIZE_LARGE - PADDING; position.y += LINE_HEIGHT + (EditorGUIUtility.isProSkin ? 0f : SPACING); EditorGUI.PropertyField(position, folderRecursive, GUIContent.none); position.y += LINE_HEIGHT + SPACING + (EditorGUIUtility.isProSkin ? SPACING : 0f); EditorGUI.PropertyField(position, smallIcon, GUIContent.none); position.y += LINE_HEIGHT + SPACING; EditorGUI.PropertyField(position, largeIcon, GUIContent.none); // Preview position.x += position.width + PADDING; position.y = originalPosition.y + LINE_HEIGHT + SPACING + 5f; 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()); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Rect originalPosition = position; SerializedProperty folderColor = property.FindPropertyRelative("Color"); SerializedProperty smallIcon = property.FindPropertyRelative("SmallIcon"); SerializedProperty largeIcon = property.FindPropertyRelative("LargeIcon"); SerializedProperty background = property.FindPropertyRelative("Background"); // 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"); position.y += LINE_HEIGHT; EditorGUI.LabelField(position, "Background"); // Values position.x += LABELS_WIDTH; position.y = originalPosition.y + PADDING; position.width = originalPosition.width - LABELS_WIDTH - PREVIEW_SIZE_LARGE - PADDING; EditorGUI.PropertyField(position, folderColor, GUIContent.none); position.y += LINE_HEIGHT; EditorGUI.PropertyField(position, smallIcon, GUIContent.none); position.y += LINE_HEIGHT; EditorGUI.PropertyField(position, largeIcon, GUIContent.none); position.y += LINE_HEIGHT; EditorGUI.PropertyField(position, background, 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()); position.y = originalPosition.y + PREVIEW_SIZE_LARGE; position.width = PREVIEW_SIZE_LARGE; position.height = 10f; if (background.objectReferenceValue != null) { GUI.DrawTexture(position, (Texture2D)background.objectReferenceValue); } }
public static RainbowFoldersSettings Load() { var settings = Resources.Load <RainbowFoldersSettings>(RESOURCE_NAME); if (settings == null) { RainbowFoldersEditorUtility.CreateAsset <RainbowFoldersSettings>(RESOURCE_NAME, "Assets/Resources"); settings = Resources.Load <RainbowFoldersSettings>(RESOURCE_NAME); } return(settings); }
private void ButtonPresets(Rect rect) { var icon = RainbowFoldersEditorUtility.GetPresetsButtonIcon(); if (!GUI.Button(rect, new GUIContent(icon, "Presets"), GUIStyle.none)) { return; } RainbowFoldersPresetsMenu.ShowDropDown(rect, _currentFolder); }
//--------------------------------------------------------------------- // 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 void ButtonDefault(Rect rect) { var icon = RainbowFoldersEditorUtility.GetDeleteButtonIcon(); if (!GUI.Button(rect, new GUIContent(icon, "Revert to Default"), GUIStyle.none)) { return; } _currentFolder.IsRecursive = false; _currentFolder.SmallIcon = null; _currentFolder.LargeIcon = null; }
//--------------------------------------------------------------------- // 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(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var originalPosition = position; var folderTag = property.FindPropertyRelative("Tag"); 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 Tag"); 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, folderTag, 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()); }
private static void DrawEditIcon(string guid, Rect rect) { if ((Event.current.modifiers & RainbowFoldersPreferences.ModifierKey) == EventModifiers.None) { _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(guid, rect, editIcon, isSmall); if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) { ShowPopupWindow(rect, path); } EditorApplication.RepaintProjectWindow(); }
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); } #endif } if (_isCollabEnabled()) { var background = RainbowFoldersEditorUtility.GetCollabBackground(isSmall, EditorGUIUtility.isProSkin); GUI.DrawTexture(rect, background); GUI.DrawTexture(rect, texture); _drawCollabOverlay(guid, rect); } else if (_isVcsEnabled()) { var iconRect = (!isSmall) ? rect : new Rect(rect.x + 7, rect.y, rect.width, rect.height); GUI.DrawTexture(iconRect, texture); _drawVcsOverlay(guid, rect); } else { GUI.DrawTexture(rect, texture); } }
//--------------------------------------------------------------------- // 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, "Recursive"); 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 - 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 - (EditorGUIUtility.isProSkin ? SPACING : 0f); rect.width -= PREVIEW_SIZE_LARGE + PADDING; _currentFolder.IsRecursive = EditorGUI.Toggle(rect, _currentFolder.IsRecursive); rect.y += LINE_HEIGHT + SPACING + (EditorGUIUtility.isProSkin ? SPACING : 0f); _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 + LINE_HEIGHT + 6f; 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); }
//--------------------------------------------------------------------- // Helpers //--------------------------------------------------------------------- private static Vector2 CalcWindowPosition() { return(RainbowFoldersEditorUtility.GetProjectWindow().position.position + new Vector2(10f, 30f)); }