1.8.5: Marking history elements as favorites will move them to the top of the list

This commit is contained in:
Anders Ejlersen 2023-03-28 18:31:47 +02:00
parent 5a2dcf3619
commit 959f012d80
7 changed files with 148 additions and 29 deletions

View file

@ -48,33 +48,47 @@ namespace Module.NavigationTool.Editor.History
viewSearchList.Draw(this, rectList, styles);
HandleClickEvent();
if (Event.current.type == EventType.Repaint && position.Contains(Event.current.mousePosition))
Repaint();
}
private void HandleClickEvent()
{
if (!EditorHistoryGUIUtility.isClicked)
return;
EditorHistoryList editorHistoryList = EditorHistoryUtility.GetHistoryList();
Object obj = editorHistoryList.GetObject(EditorHistoryGUIUtility.currentEntry);
if (obj != null)
if (EditorHistoryGUIUtility.isPinClicked)
{
if (EditorHistoryGUIUtility.isDoubleClick)
{
AssetDatabase.OpenAsset(obj);
}
if (EditorHistoryGUIUtility.isCurrentEntryPinned)
editorHistoryList.Unpin(EditorHistoryGUIUtility.currentEntry);
else
editorHistoryList.Pin(EditorHistoryGUIUtility.currentEntry);
}
else
{
Object obj = editorHistoryList.GetObject(EditorHistoryGUIUtility.currentEntry);
if (obj != null)
{
EditorHistoryListPostProcess.IgnoreNextSelectionChange();
if (EditorHistoryGUIUtility.isDoubleClick)
{
AssetDatabase.OpenAsset(obj);
}
else
{
EditorHistoryListPostProcess.IgnoreNextSelectionChange();
if (EditorHistoryPrefs.IsSetAsActiveObjectEnabled)
Selection.activeObject = obj;
if (EditorHistoryPrefs.IsSetAsActiveObjectEnabled)
Selection.activeObject = obj;
EditorGUIUtility.PingObject(obj);
EditorGUIUtility.PingObject(obj);
}
}
}
EditorHistoryGUIUtility.Used();
}

View file

@ -7,10 +7,17 @@ namespace Module.NavigationTool.Editor.History
{
public GUIStyle toolbox;
public GUIStyle icon;
public GUIStyle entry;
public GUIStyle invalidEntry;
public GUIContent iconSearch;
public GUIContent iconPinned;
public GUIContent iconUnpinned;
public Color colorNone;
public Color colorToggleOff;
public Color colorToggleOn;
private GUISkin skin;
@ -21,7 +28,13 @@ namespace Module.NavigationTool.Editor.History
this.skin = skin;
toolbox = new GUIStyle(skin.box);
icon = new GUIStyle
{
imagePosition = ImagePosition.ImageOnly,
padding = new RectOffset(4, 0, 1, 0)
};
entry = new GUIStyle(skin.label);
entry.hover.textColor = entry.onHover.textColor = Color.white;
entry.active.textColor = entry.onActive.textColor = Color.yellow;
@ -32,6 +45,12 @@ namespace Module.NavigationTool.Editor.History
invalidEntry.active.textColor = invalidEntry.onActive.textColor = new Color(1.0f, 0.0f, 0.5f);
iconSearch = EditorGUIUtility.IconContent("d_Search Icon");
iconPinned = EditorGUIUtility.IconContent("d_Favorite");
iconUnpinned = EditorGUIUtility.IconContent("Favorite");
colorNone = new Color(1.0f, 1.0f, 1.0f, 0.0f);
colorToggleOff = new Color(1.0f, 1.0f, 1.0f, 0.5f);
colorToggleOn = new Color(1.0f, 1.0f, 1.0f, 1.0f);
}
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@ -34,6 +35,17 @@ namespace Module.NavigationTool.Editor.History
scrollPosition = GUI.BeginScrollView(position, scrollPosition, viewRect);
{
for (int i = editorHistoryList.pinnedEntries.Count - 1; i >= 0; i--)
{
EditorHistoryList.Entry e = editorHistoryList.pinnedEntries[i];
if (isSearching && !e.lowerName.Contains(lowerSearchStr))
continue;
EditorHistoryGUIUtility.DrawEntry(entryRect, editorHistoryList.pinnedEntries[i], styles, true);
entryRect.y += entryHeight;
}
for (int i = editorHistoryList.entries.Count - 1; i >= 0; i--)
{
EditorHistoryList.Entry e = editorHistoryList.entries[i];
@ -41,7 +53,7 @@ namespace Module.NavigationTool.Editor.History
if (isSearching && !e.lowerName.Contains(lowerSearchStr))
continue;
EditorHistoryGUIUtility.DrawEntry(entryRect, editorHistoryList.entries[i], styles, true);
EditorHistoryGUIUtility.DrawEntry(entryRect, editorHistoryList.entries[i], styles, false);
entryRect.y += entryHeight;
}
}