0.4.0: Added double-click open to Favorites and History
This commit is contained in:
parent
9b73200c73
commit
d35a79faf1
6 changed files with 59 additions and 5 deletions
|
|
@ -9,8 +9,13 @@ namespace Game.NavigationTool.Editor.History
|
|||
private static readonly int ENTRY_HASH = "DrawHistoryEntry".GetHashCode();
|
||||
|
||||
public static bool isClicked;
|
||||
public static bool isDoubleClick;
|
||||
public static HistoryList.Entry currentEntry;
|
||||
|
||||
private static HistoryList.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)
|
||||
{
|
||||
int id = GUIUtility.GetControlID(ENTRY_HASH, FocusType.Passive, rect);
|
||||
|
|
@ -31,6 +36,24 @@ namespace Game.NavigationTool.Editor.History
|
|||
{
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,9 +60,16 @@ namespace Game.NavigationTool.Editor.History
|
|||
|
||||
if (obj != null)
|
||||
{
|
||||
HistoryListPostProcess.IgnoreNextSelectionChange();
|
||||
Selection.activeObject = obj;
|
||||
EditorGUIUtility.PingObject(obj);
|
||||
if (HistoryGUIUtility.isDoubleClick)
|
||||
{
|
||||
AssetDatabase.OpenAsset(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
HistoryListPostProcess.IgnoreNextSelectionChange();
|
||||
Selection.activeObject = obj;
|
||||
EditorGUIUtility.PingObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
HistoryGUIUtility.Used();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue