private void DrawElementHorizontalContent(Object elementObject, GUIStyle labelStyle, Color?labelColor, bool hovered) { Color originalContentColor = GUI.contentColor; // Draw the favorites button. if (favoritesEnabled) { bool isFavorite = selectionHistory.IsFavorite(elementObject); GUIContent pinContent = GetPinButtonContent(isFavorite); GUI.contentColor = hovered || isFavorite ? originalContentColor : Color.clear; if (GUILayout.Button(pinContent, miniButtonStyle)) { selectionHistory.ToggleFavorite(elementObject); Repaint(); } } // Left padding. GUILayout.Space(LINE_HEIGHT / 2f); // Build label content. GUIContent labelContent = new GUIContent(); labelContent.image = AssetPreview.GetMiniThumbnail(elementObject); labelContent.text = elementObject.name; // Draw the label. GUI.contentColor = labelColor.HasValue ? labelColor.Value : originalContentColor; Rect labelRect = GUILayoutUtility.GetRect(labelContent, labelStyle, minWidth, lineHeight); GUI.Label(labelRect, labelContent, labelStyle); GUI.contentColor = originalContentColor; }
void DrawElement(Object obj, int i, Color originalColor) { var buttonStyle = windowSkin.GetStyle("SelectionButton"); buttonStyle.fixedWidth = position.width - buttonsWidth; var nonSelectedColor = originalColor; if (!EditorUtility.IsPersistent(obj)) { if (!showHierarchyViewObjects) { return; } nonSelectedColor = hierarchyElementColor; } else { if (!showProjectViewObjects) { return; } } if (selectionHistory.IsSelected(obj)) { GUI.contentColor = selectedElementColor; } else { GUI.contentColor = nonSelectedColor; } var rect = EditorGUILayout.BeginHorizontal(); if (obj == null) { GUILayout.Label("Deleted", buttonStyle); } else { var icon = AssetPreview.GetMiniThumbnail(obj); GUIContent content = new GUIContent(); content.image = icon; content.text = obj.name; // chnanged to label to be able to handle events for drag GUILayout.Label(content, buttonStyle); GUI.contentColor = originalColor; if (GUILayout.Button("Ping", windowSkin.button)) { EditorGUIUtility.PingObject(obj); } var favoritesEnabled = EditorPrefs.GetBool(HistoryFavoritesPrefKey, true); if (favoritesEnabled) { var pinString = "Pin"; var isFavorite = selectionHistory.IsFavorite(obj); if (isFavorite) { pinString = "Unpin"; } if (GUILayout.Button(pinString, windowSkin.button)) { selectionHistory.ToggleFavorite(obj); Repaint(); } } } EditorGUILayout.EndHorizontal(); ButtonLogic(rect, obj); }