private void DrawHistory() { var history = selectionHistory.History; for (int i = 0; i < history.Count; i++) { var historyElement = history[i]; if (selectionHistory.IsFavorite(historyElement) && favoritesEnabled) { continue; // Skip elements that show up in the favorites. } else { DrawElement(historyElement); } } }
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); }