1.8.4: History received a fix for startup issue, increased entry size, and context menu options
- Set selection active in history is now a toggleable feature in the context menu - Increased number of entries in history from 32 to 64 - Clear entries moved to context menu in history - Fixed issue, where history didn't work on first startup
This commit is contained in:
parent
305aa13317
commit
5a2dcf3619
13
CHANGELOG.md
13
CHANGELOG.md
|
|
@ -1,6 +1,19 @@
|
|||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [1.8.4] - 2023-03-27
|
||||
|
||||
### Added
|
||||
- Set selection active in history is now a toggleable feature in the context menu
|
||||
|
||||
### Changed
|
||||
- Increased number of entries in history from 32 to 64
|
||||
- Clear entries moved to context menu in history
|
||||
|
||||
### Fixed
|
||||
- Fixed issue, where history didn't work on first startup
|
||||
|
||||
|
||||
## [1.8.3] - 2023-03-16
|
||||
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@ using UnityEngine;
|
|||
|
||||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
internal static class HistoryGUIUtility
|
||||
internal static class EditorHistoryGUIUtility
|
||||
{
|
||||
private static readonly int ENTRY_HASH = "DrawHistoryEntry".GetHashCode();
|
||||
|
||||
public static bool isClicked;
|
||||
public static bool isDoubleClick;
|
||||
public static HistoryList.Entry currentEntry;
|
||||
public static EditorHistoryList.Entry currentEntry;
|
||||
|
||||
private static HistoryList.Entry LAST_CLICK_ENTRY;
|
||||
private static EditorHistoryList.Entry LAST_CLICK_ENTRY;
|
||||
private static double LAST_CLICK_TIME;
|
||||
private static int CLICK_COUNT;
|
||||
|
||||
public static void DrawEntry(Rect rect, HistoryList.Entry entry, Styles styles, bool ignoreIndentLevel = false)
|
||||
public static void DrawEntry(Rect rect, EditorHistoryList.Entry entry, Styles styles, bool ignoreIndentLevel = false)
|
||||
{
|
||||
int id = GUIUtility.GetControlID(ENTRY_HASH, FocusType.Passive, rect);
|
||||
bool on = currentEntry == entry;
|
||||
|
|
@ -9,14 +9,14 @@ using Object = UnityEngine.Object;
|
|||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class HistoryList
|
||||
internal sealed class EditorHistoryList
|
||||
{
|
||||
public static readonly string PREF_ID = "PREF_HISTORY_LIST";
|
||||
public const int MAX_LENGTH = 32;
|
||||
public const int MAX_LENGTH = 64;
|
||||
|
||||
public List<Entry> entries;
|
||||
|
||||
public HistoryList()
|
||||
public EditorHistoryList()
|
||||
{
|
||||
entries = new List<Entry>();
|
||||
string json = EditorProjectPrefs.GetString(PREF_ID);
|
||||
|
|
@ -134,10 +134,10 @@ namespace Module.NavigationTool.Editor.History
|
|||
public void Refresh()
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
name = Path.GetFileNameWithoutExtension(path);
|
||||
lowerName = name.ToLower();
|
||||
name = AssetDatabase.IsValidFolder(path) ? Path.GetFileName(path) : Path.GetFileNameWithoutExtension(path);
|
||||
lowerName = !string.IsNullOrEmpty(name) ? name.ToLower() : string.Empty;
|
||||
valid = AssetDatabase.LoadMainAssetAtPath(path) != null;
|
||||
content = new GUIContent(name, HistoryGUIUtility.GetIcon(path), path);
|
||||
content = new GUIContent(name, EditorHistoryGUIUtility.GetIcon(path), path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
internal sealed class HistoryListPostProcess : AssetPostprocessor
|
||||
[InitializeOnLoad]
|
||||
internal sealed class EditorHistoryListPostProcess : AssetPostprocessor
|
||||
{
|
||||
private static bool IGNORE_NEXT_SELECTION_CHANGE;
|
||||
|
||||
static HistoryListPostProcess()
|
||||
static EditorHistoryListPostProcess()
|
||||
{
|
||||
Selection.selectionChanged -= OnSelectionChanged;
|
||||
Selection.selectionChanged += OnSelectionChanged;
|
||||
}
|
||||
|
||||
|
|
@ -17,8 +19,13 @@ namespace Module.NavigationTool.Editor.History
|
|||
movedAssets.Length != 0 ||
|
||||
movedFromAssetPaths.Length != 0;
|
||||
|
||||
if (isDirty && HistoryUtility.IsLoaded())
|
||||
HistoryUtility.RefreshAll();
|
||||
if (isDirty && EditorHistoryUtility.IsLoaded())
|
||||
EditorHistoryUtility.RefreshAll();
|
||||
}
|
||||
|
||||
public static void IgnoreNextSelectionChange()
|
||||
{
|
||||
IGNORE_NEXT_SELECTION_CHANGE = true;
|
||||
}
|
||||
|
||||
private static void OnSelectionChanged()
|
||||
|
|
@ -32,15 +39,10 @@ namespace Module.NavigationTool.Editor.History
|
|||
}
|
||||
else
|
||||
{
|
||||
HistoryList historyList = HistoryUtility.GetHistoryList();
|
||||
historyList.AddRange(Selection.assetGUIDs);
|
||||
HistoryGUIUtility.Repaint();
|
||||
EditorHistoryList editorHistoryList = EditorHistoryUtility.GetHistoryList();
|
||||
editorHistoryList.AddRange(Selection.assetGUIDs);
|
||||
EditorHistoryGUIUtility.Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public static void IgnoreNextSelectionChange()
|
||||
{
|
||||
IGNORE_NEXT_SELECTION_CHANGE = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Editor/History/Utilities/EditorHistoryPrefs.cs
Normal file
15
Editor/History/Utilities/EditorHistoryPrefs.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
internal static class EditorHistoryPrefs
|
||||
{
|
||||
private const string PREF_IS_SET_AS_ACTIVE_OBJECT_ENABLED = "EditorHistoryWindow.IsSetAsActiveObjectEnabled";
|
||||
|
||||
public static bool IsSetAsActiveObjectEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_SET_AS_ACTIVE_OBJECT_ENABLED, true);
|
||||
set => EditorPrefs.SetBool(PREF_IS_SET_AS_ACTIVE_OBJECT_ENABLED, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/History/Utilities/EditorHistoryPrefs.cs.meta
Normal file
3
Editor/History/Utilities/EditorHistoryPrefs.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8673b42e45bc489988f66cbd2ebd1eb5
|
||||
timeCreated: 1679940554
|
||||
37
Editor/History/Utilities/EditorHistoryUtility.cs
Normal file
37
Editor/History/Utilities/EditorHistoryUtility.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
internal static class EditorHistoryUtility
|
||||
{
|
||||
private static EditorHistoryList EDITOR_HISTORY_LIST;
|
||||
|
||||
static EditorHistoryUtility()
|
||||
{
|
||||
EDITOR_HISTORY_LIST = null;
|
||||
}
|
||||
|
||||
public static EditorHistoryList GetHistoryList()
|
||||
{
|
||||
return EDITOR_HISTORY_LIST ?? (EDITOR_HISTORY_LIST = new EditorHistoryList());
|
||||
}
|
||||
|
||||
public static bool IsLoaded()
|
||||
{
|
||||
return EDITOR_HISTORY_LIST != null;
|
||||
}
|
||||
|
||||
public static void RefreshAll()
|
||||
{
|
||||
if (EDITOR_HISTORY_LIST == null)
|
||||
return;
|
||||
|
||||
List<EditorHistoryList.Entry> entries = EDITOR_HISTORY_LIST.entries;
|
||||
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
entries[i].Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
internal static class HistoryUtility
|
||||
{
|
||||
private static HistoryList HISTORY_LIST;
|
||||
|
||||
static HistoryUtility()
|
||||
{
|
||||
HISTORY_LIST = null;
|
||||
}
|
||||
|
||||
public static HistoryList GetHistoryList()
|
||||
{
|
||||
return HISTORY_LIST ?? (HISTORY_LIST = new HistoryList());
|
||||
}
|
||||
|
||||
public static bool IsLoaded()
|
||||
{
|
||||
return HISTORY_LIST != null;
|
||||
}
|
||||
|
||||
public static void RefreshAll()
|
||||
{
|
||||
if (HISTORY_LIST == null)
|
||||
return;
|
||||
|
||||
List<HistoryList.Entry> entries = HISTORY_LIST.entries;
|
||||
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
entries[i].Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ using Object = UnityEngine.Object;
|
|||
|
||||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
internal sealed class EditorHistoryWindow : EditorWindow
|
||||
internal sealed class EditorHistoryWindow : EditorWindow, IHasCustomMenu
|
||||
{
|
||||
[NonSerialized]
|
||||
private Styles styles;
|
||||
|
|
@ -38,8 +38,8 @@ namespace Module.NavigationTool.Editor.History
|
|||
return;
|
||||
|
||||
styles.Initialize(GUI.skin);
|
||||
var rectTools = new Rect(0.0f, 0.0f, position.width, EditorGUIUtility.singleLineHeight);
|
||||
var rectList = new Rect(0.0f, rectTools.yMax, position.width, position.height - rectTools.height);
|
||||
var rectTools = new Rect(0.0f, 4.0f, position.width, EditorGUIUtility.singleLineHeight);
|
||||
var rectList = new Rect(0.0f, rectTools.yMax + 4.0f, position.width, position.height - rectTools.height - 8.0f);
|
||||
|
||||
viewTools.Initialize();
|
||||
viewTools.Draw(this, rectTools, styles);
|
||||
|
|
@ -52,27 +52,43 @@ namespace Module.NavigationTool.Editor.History
|
|||
|
||||
private void HandleClickEvent()
|
||||
{
|
||||
if (!HistoryGUIUtility.isClicked)
|
||||
if (!EditorHistoryGUIUtility.isClicked)
|
||||
return;
|
||||
|
||||
HistoryList historyList = HistoryUtility.GetHistoryList();
|
||||
Object obj = historyList.GetObject(HistoryGUIUtility.currentEntry);
|
||||
EditorHistoryList editorHistoryList = EditorHistoryUtility.GetHistoryList();
|
||||
Object obj = editorHistoryList.GetObject(EditorHistoryGUIUtility.currentEntry);
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
if (HistoryGUIUtility.isDoubleClick)
|
||||
if (EditorHistoryGUIUtility.isDoubleClick)
|
||||
{
|
||||
AssetDatabase.OpenAsset(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
HistoryListPostProcess.IgnoreNextSelectionChange();
|
||||
EditorHistoryListPostProcess.IgnoreNextSelectionChange();
|
||||
|
||||
if (EditorHistoryPrefs.IsSetAsActiveObjectEnabled)
|
||||
Selection.activeObject = obj;
|
||||
|
||||
EditorGUIUtility.PingObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
HistoryGUIUtility.Used();
|
||||
EditorHistoryGUIUtility.Used();
|
||||
}
|
||||
|
||||
void IHasCustomMenu.AddItemsToMenu(GenericMenu menu)
|
||||
{
|
||||
menu.AddItem(new GUIContent("Clear"),
|
||||
false,
|
||||
() => EditorHistoryUtility.GetHistoryList()?.Clear());
|
||||
|
||||
menu.AddSeparator("");
|
||||
|
||||
menu.AddItem(new GUIContent("Active object in selection"),
|
||||
EditorHistoryPrefs.IsSetAsActiveObjectEnabled,
|
||||
() => EditorHistoryPrefs.IsSetAsActiveObjectEnabled = !EditorHistoryPrefs.IsSetAsActiveObjectEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
|
|
@ -9,6 +10,8 @@ namespace Module.NavigationTool.Editor.History
|
|||
public GUIStyle entry;
|
||||
public GUIStyle invalidEntry;
|
||||
|
||||
public GUIContent iconSearch;
|
||||
|
||||
private GUISkin skin;
|
||||
|
||||
public void Initialize(GUISkin skin)
|
||||
|
|
@ -27,6 +30,8 @@ namespace Module.NavigationTool.Editor.History
|
|||
invalidEntry.normal.textColor = Color.red;
|
||||
invalidEntry.hover.textColor = invalidEntry.onHover.textColor = new Color(1.0f, 0.3f, 0.3f);
|
||||
invalidEntry.active.textColor = invalidEntry.onActive.textColor = new Color(1.0f, 0.0f, 0.5f);
|
||||
|
||||
iconSearch = EditorGUIUtility.IconContent("d_Search Icon");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,17 +11,17 @@ namespace Module.NavigationTool.Editor.History
|
|||
private Vector2 scrollPosition;
|
||||
|
||||
[NonSerialized]
|
||||
private HistoryList historyList;
|
||||
private EditorHistoryList editorHistoryList;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
historyList = HistoryUtility.GetHistoryList();
|
||||
editorHistoryList = EditorHistoryUtility.GetHistoryList();
|
||||
}
|
||||
|
||||
public override void Draw(EditorHistoryWindow window, Rect rect, Styles styles)
|
||||
{
|
||||
float entryHeight = EditorGUIUtility.singleLineHeight;
|
||||
float height = entryHeight * historyList.entries.Count;
|
||||
float height = entryHeight * editorHistoryList.entries.Count;
|
||||
|
||||
bool isSearching = !string.IsNullOrEmpty(window.viewTools.searchStr);
|
||||
string lowerSearchStr = window.viewTools.searchStr.ToLower();
|
||||
|
|
@ -34,14 +34,14 @@ namespace Module.NavigationTool.Editor.History
|
|||
|
||||
scrollPosition = GUI.BeginScrollView(position, scrollPosition, viewRect);
|
||||
{
|
||||
for (int i = historyList.entries.Count - 1; i >= 0; i--)
|
||||
for (int i = editorHistoryList.entries.Count - 1; i >= 0; i--)
|
||||
{
|
||||
HistoryList.Entry e = historyList.entries[i];
|
||||
EditorHistoryList.Entry e = editorHistoryList.entries[i];
|
||||
|
||||
if (isSearching && !e.lowerName.Contains(lowerSearchStr))
|
||||
continue;
|
||||
|
||||
HistoryGUIUtility.DrawEntry(entryRect, historyList.entries[i], styles, true);
|
||||
EditorHistoryGUIUtility.DrawEntry(entryRect, editorHistoryList.entries[i], styles, true);
|
||||
entryRect.y += entryHeight;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,26 +9,27 @@ namespace Module.NavigationTool.Editor.History
|
|||
{
|
||||
public string searchStr = string.Empty;
|
||||
|
||||
[NonSerialized]
|
||||
private HistoryList historyList;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
historyList = HistoryUtility.GetHistoryList();
|
||||
}
|
||||
|
||||
public override void Draw(EditorHistoryWindow window, Rect rect, Styles styles)
|
||||
{
|
||||
const float PADDING = 4.0f;
|
||||
const float ICON_SIZE = 20.0f;
|
||||
const float BUTTON_SIZE = 50.0f;
|
||||
|
||||
GUI.BeginGroup(rect, styles.toolbox);
|
||||
{
|
||||
var r0 = new Rect(0.0f, 0.0f, rect.width - BUTTON_SIZE, rect.height);
|
||||
var r1 = new Rect(r0.xMax, 0.0f, BUTTON_SIZE, rect.height);
|
||||
searchStr = EditorGUI.TextField(r0, searchStr);
|
||||
var r0 = new Rect(PADDING, 0.0f, ICON_SIZE, rect.height);
|
||||
var r1 = new Rect(r0.xMax, 0.0f, rect.width - BUTTON_SIZE - ICON_SIZE - PADDING * 2.0f, rect.height);
|
||||
var r2 = new Rect(r1.xMax, 0.0f, BUTTON_SIZE, rect.height);
|
||||
|
||||
if (GUI.Button(r1, "Clear"))
|
||||
historyList.Clear();
|
||||
GUI.Label(r0, styles.iconSearch);
|
||||
searchStr = EditorGUI.TextField(r1, searchStr);
|
||||
|
||||
if (GUI.Button(r2, "Clear"))
|
||||
searchStr = string.Empty;
|
||||
}
|
||||
GUI.EndGroup();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.module.navigationtool",
|
||||
"version": "1.8.3",
|
||||
"version": "1.8.4",
|
||||
"displayName": "Module.NavigationTool",
|
||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||
"unity": "2019.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue