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
98
Editor/History/Utilities/EditorHistoryGUIUtility.cs
Normal file
98
Editor/History/Utilities/EditorHistoryGUIUtility.cs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.NavigationTool.Editor.History
|
||||
{
|
||||
internal static class EditorHistoryGUIUtility
|
||||
{
|
||||
private static readonly int ENTRY_HASH = "DrawHistoryEntry".GetHashCode();
|
||||
|
||||
public static bool isClicked;
|
||||
public static bool isDoubleClick;
|
||||
public static EditorHistoryList.Entry currentEntry;
|
||||
|
||||
private static EditorHistoryList.Entry LAST_CLICK_ENTRY;
|
||||
private static double LAST_CLICK_TIME;
|
||||
private static int CLICK_COUNT;
|
||||
|
||||
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;
|
||||
bool intersects = rect.Contains(Event.current.mousePosition);
|
||||
|
||||
switch (Event.current.type)
|
||||
{
|
||||
case EventType.MouseDown:
|
||||
if (intersects)
|
||||
{
|
||||
currentEntry = entry;
|
||||
Event.current.Use();
|
||||
}
|
||||
break;
|
||||
case EventType.MouseUp:
|
||||
if (currentEntry == entry)
|
||||
{
|
||||
isClicked = intersects;
|
||||
|
||||
if (isClicked)
|
||||
{
|
||||
double dt = EditorApplication.timeSinceStartup - LAST_CLICK_TIME;
|
||||
|
||||
if (dt < 0.3 && CLICK_COUNT == 1 && LAST_CLICK_ENTRY == entry)
|
||||
CLICK_COUNT++;
|
||||
else
|
||||
CLICK_COUNT = 1;
|
||||
|
||||
LAST_CLICK_ENTRY = entry;
|
||||
LAST_CLICK_TIME = EditorApplication.timeSinceStartup;
|
||||
isDoubleClick = CLICK_COUNT == 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentEntry = null;
|
||||
}
|
||||
|
||||
if (!isClicked)
|
||||
currentEntry = null;
|
||||
|
||||
Event.current.Use();
|
||||
}
|
||||
break;
|
||||
case EventType.Repaint:
|
||||
Vector2 oldSize = EditorGUIUtility.GetIconSize();
|
||||
EditorGUIUtility.SetIconSize(new Vector2(rect.height, rect.height));
|
||||
GUIStyle style = entry.valid ? styles.entry : styles.invalidEntry;
|
||||
style.Draw(rect, entry.content, id, on, intersects);
|
||||
EditorGUIUtility.SetIconSize(oldSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Used()
|
||||
{
|
||||
isClicked = false;
|
||||
currentEntry = null;
|
||||
}
|
||||
|
||||
public static Texture2D GetIcon(string path)
|
||||
{
|
||||
var texture = AssetDatabase.GetCachedIcon(path) as Texture2D;
|
||||
|
||||
if (texture == null)
|
||||
texture = InternalEditorUtility.GetIconForFile(path);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static void Repaint()
|
||||
{
|
||||
if (!EditorWindow.HasOpenInstances<EditorHistoryWindow>())
|
||||
return;
|
||||
|
||||
var window = EditorWindow.GetWindow<EditorHistoryWindow>("History", false);
|
||||
window.Repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue