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
17 changed files with 141 additions and 86 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue