0.4.0: Added double-click open to Favorites and History
This commit is contained in:
parent
9b73200c73
commit
d35a79faf1
|
|
@ -5,6 +5,7 @@
|
|||
None,
|
||||
BeginClick,
|
||||
PerformedClick,
|
||||
PerformedDoubleClick,
|
||||
EndClick,
|
||||
BeginContextClick,
|
||||
PerformedContextClick,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ namespace Game.NavigationTool.Editor.Favorite
|
|||
public static EManipulatingState manipulatingState;
|
||||
public static Vector2 manipulatingMouseOffset;
|
||||
public static Rect manipulatingRect;
|
||||
|
||||
private static Favorites.Entry LAST_CLICK_ENTRY;
|
||||
private static double LAST_CLICK_TIME;
|
||||
private static int CLICK_COUNT;
|
||||
|
||||
public static Favorites.Entry hoverEntry;
|
||||
|
||||
|
|
@ -40,9 +44,22 @@ namespace Game.NavigationTool.Editor.Favorite
|
|||
if (manipulatingState == EManipulatingState.BeginClick)
|
||||
{
|
||||
if (intersects && Event.current.button == 0)
|
||||
SetManipulating(rect, entry, EManipulatingState.PerformedClick);
|
||||
{
|
||||
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;
|
||||
SetManipulating(rect, entry, CLICK_COUNT == 1 ? EManipulatingState.PerformedClick : EManipulatingState.PerformedDoubleClick);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetManipulating(rect, entry, EManipulatingState.EndClick);
|
||||
}
|
||||
}
|
||||
else if (manipulatingState == EManipulatingState.BeginContextClick)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -101,6 +101,12 @@ namespace Game.NavigationTool.Editor.Favorite
|
|||
favorites.Save();
|
||||
}
|
||||
|
||||
FavoritesGUIUtility.ClearManipulating();
|
||||
break;
|
||||
case EManipulatingState.PerformedDoubleClick:
|
||||
if (entry.isAsset)
|
||||
AssetDatabase.OpenAsset(favorites.GetObject(entry));
|
||||
|
||||
FavoritesGUIUtility.ClearManipulating();
|
||||
break;
|
||||
case EManipulatingState.BeginDrag:
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.module.navigationtool",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"displayName": "Module.NavigationTool",
|
||||
"description": "Support for navigation tools, like favorites and history",
|
||||
"unity": "2019.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue