0.3.0: Added history list
This commit is contained in:
parent
1e1736f94a
commit
9b73200c73
|
|
@ -1,4 +1,4 @@
|
|||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
public enum EManipulatingState : byte
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using UnityEditor;
|
|||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class Favorites : ISerializationCallbackReceiver
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal static class FavoritesGUIUtility
|
||||
{
|
||||
private static readonly int ENTRY_HASH = "DrawEntry".GetHashCode();
|
||||
private static readonly int ENTRY_HASH = "DrawFavoriteEntry".GetHashCode();
|
||||
|
||||
public static Favorites.Entry manipulatingEntry;
|
||||
public static EManipulatingState manipulatingState;
|
||||
|
|
@ -79,8 +79,11 @@ namespace Game.NavigationTool.Editor
|
|||
if (!entry.isAsset)
|
||||
entry.content.image = entry.expanded ? styles.foldoutOut : styles.foldoutIn;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal sealed class FavoritesPostProcess : AssetPostprocessor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal static class FavoritesUtility
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal sealed class EditorFavoritesPopupWindowAddFolder : PopupWindowContent
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal sealed class EditorFavoritesPopupWindowContextMenu : PopupWindowContent
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal sealed class EditorFavoritesPopupWindowRenameFolder : PopupWindowContent
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal sealed class EditorFavoritesWindow : EditorWindow
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal sealed class Styles
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
internal abstract class AbstractEditorFavoritesView
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class EditorFavoritesViewSearchList : AbstractEditorFavoritesView
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class EditorFavoritesViewTools : AbstractEditorFavoritesView
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
namespace Game.NavigationTool.Editor.Favorite
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class EditorFavoritesViewTreeList : AbstractEditorFavoritesView
|
||||
|
|
|
|||
8
Editor/History.meta
Normal file
8
Editor/History.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7bbcde81c1d70cb419a781a2ac8b3f94
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor/History/Utilities.meta
Normal file
8
Editor/History/Utilities.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6f86cbee736eef748b28697927b877b4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
75
Editor/History/Utilities/HistoryGUIUtility.cs
Normal file
75
Editor/History/Utilities/HistoryGUIUtility.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor.History
|
||||
{
|
||||
internal static class HistoryGUIUtility
|
||||
{
|
||||
private static readonly int ENTRY_HASH = "DrawHistoryEntry".GetHashCode();
|
||||
|
||||
public static bool isClicked;
|
||||
public static HistoryList.Entry currentEntry;
|
||||
|
||||
public static void DrawEntry(Rect rect, HistoryList.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)
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/History/Utilities/HistoryGUIUtility.cs.meta
Normal file
11
Editor/History/Utilities/HistoryGUIUtility.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fd4d5beff36f41d40ac4a5a495488f8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
143
Editor/History/Utilities/HistoryList.cs
Normal file
143
Editor/History/Utilities/HistoryList.cs
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Game.NavigationTool.Editor.History
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class HistoryList
|
||||
{
|
||||
public static readonly string PREF_ID = "PREF_HISTORY_LIST";
|
||||
public const int MAX_LENGTH = 32;
|
||||
|
||||
public List<Entry> entries;
|
||||
|
||||
public HistoryList()
|
||||
{
|
||||
entries = new List<Entry>();
|
||||
string json = EditorPrefs.GetString(PREF_ID);
|
||||
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
EditorJsonUtility.FromJsonOverwrite(json, this);
|
||||
}
|
||||
|
||||
public void Add(string guid)
|
||||
{
|
||||
if (InternalAddEntry(new Entry(guid)))
|
||||
Save();
|
||||
}
|
||||
|
||||
private bool InternalAddEntry(Entry e)
|
||||
{
|
||||
e.Refresh();
|
||||
|
||||
if (!e.valid)
|
||||
return false;
|
||||
|
||||
entries.Add(e);
|
||||
|
||||
if (entries.Count > MAX_LENGTH)
|
||||
entries.RemoveRange(0, entries.Count - MAX_LENGTH);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddRange(string[] guids)
|
||||
{
|
||||
var isDirty = false;
|
||||
|
||||
for (var i = 0; i < guids.Length; i++)
|
||||
{
|
||||
if (InternalAddEntry(new Entry(guids[i])))
|
||||
isDirty = true;
|
||||
}
|
||||
|
||||
if (isDirty)
|
||||
Save();
|
||||
}
|
||||
|
||||
public void AddRangeByPath(string[] paths)
|
||||
{
|
||||
var isDirty = false;
|
||||
|
||||
for (var i = 0; i < paths.Length; i++)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(paths[i]);
|
||||
|
||||
if (InternalAddEntry(new Entry(guid)))
|
||||
isDirty = true;
|
||||
}
|
||||
|
||||
if (isDirty)
|
||||
Save();
|
||||
}
|
||||
|
||||
public void Remove(Entry e)
|
||||
{
|
||||
if (entries.Remove(e))
|
||||
Save();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
entries.Clear();
|
||||
Save();
|
||||
}
|
||||
|
||||
public Object GetObject(Entry entry)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(entry.guid);
|
||||
return AssetDatabase.LoadMainAssetAtPath(path);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
string json = EditorJsonUtility.ToJson(this, false);
|
||||
EditorPrefs.SetString(PREF_ID, json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class: Entry
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class Entry : ISerializationCallbackReceiver
|
||||
{
|
||||
public string guid;
|
||||
|
||||
[NonSerialized]
|
||||
public string name;
|
||||
[NonSerialized]
|
||||
public bool valid;
|
||||
[NonSerialized]
|
||||
public GUIContent content;
|
||||
[NonSerialized]
|
||||
public string lowerName;
|
||||
|
||||
public Entry(string guid)
|
||||
{
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
name = Path.GetFileNameWithoutExtension(path);
|
||||
lowerName = name.ToLower();
|
||||
valid = AssetDatabase.LoadMainAssetAtPath(path) != null;
|
||||
content = new GUIContent(name, HistoryGUIUtility.GetIcon(path), path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/History/Utilities/HistoryList.cs.meta
Normal file
11
Editor/History/Utilities/HistoryList.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a7c41592f12a4174885c183470ce5e91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Editor/History/Utilities/HistoryListPostProcess.cs
Normal file
46
Editor/History/Utilities/HistoryListPostProcess.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace Game.NavigationTool.Editor.History
|
||||
{
|
||||
internal sealed class HistoryListPostProcess : AssetPostprocessor
|
||||
{
|
||||
private static bool IGNORE_NEXT_SELECTION_CHANGE;
|
||||
|
||||
static HistoryListPostProcess()
|
||||
{
|
||||
Selection.selectionChanged += OnSelectionChanged;
|
||||
}
|
||||
|
||||
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
||||
{
|
||||
bool isDirty = deletedAssets.Length != 0 ||
|
||||
movedAssets.Length != 0 ||
|
||||
movedFromAssetPaths.Length != 0;
|
||||
|
||||
if (isDirty && HistoryUtility.IsLoaded())
|
||||
HistoryUtility.RefreshAll();
|
||||
}
|
||||
|
||||
private static void OnSelectionChanged()
|
||||
{
|
||||
if (Selection.assetGUIDs == null)
|
||||
return;
|
||||
|
||||
if (IGNORE_NEXT_SELECTION_CHANGE)
|
||||
{
|
||||
IGNORE_NEXT_SELECTION_CHANGE = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
HistoryList historyList = HistoryUtility.GetHistoryList();
|
||||
historyList.AddRange(Selection.assetGUIDs);
|
||||
HistoryGUIUtility.Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public static void IgnoreNextSelectionChange()
|
||||
{
|
||||
IGNORE_NEXT_SELECTION_CHANGE = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/History/Utilities/HistoryListPostProcess.cs.meta
Normal file
11
Editor/History/Utilities/HistoryListPostProcess.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2d8bd093d38234a4f9268f2fb4fc6b80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
37
Editor/History/Utilities/HistoryUtility.cs
Normal file
37
Editor/History/Utilities/HistoryUtility.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Game.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/History/Utilities/HistoryUtility.cs.meta
Normal file
11
Editor/History/Utilities/HistoryUtility.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4ceaae411c5d2e64b899ea234444354b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor/History/Window.meta
Normal file
8
Editor/History/Window.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0bcd27df5069d28488ed46453c10c44e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Editor/History/Window/EditorHistoryWindow.cs
Normal file
71
Editor/History/Window/EditorHistoryWindow.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Game.NavigationTool.Editor.History
|
||||
{
|
||||
internal sealed class EditorHistoryWindow : EditorWindow
|
||||
{
|
||||
[NonSerialized]
|
||||
private Styles styles;
|
||||
[SerializeField]
|
||||
public EditorHistoryViewTools viewTools;
|
||||
[SerializeField]
|
||||
private EditorHistoryViewSearchList viewSearchList;
|
||||
|
||||
[MenuItem("Tools/Windows/History")]
|
||||
public static void Open()
|
||||
{
|
||||
var window = GetWindow<EditorHistoryWindow>();
|
||||
window.titleContent = new GUIContent("History");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (styles == null)
|
||||
styles = new Styles();
|
||||
if (viewTools == null)
|
||||
viewTools = new EditorHistoryViewTools();
|
||||
if (viewSearchList == null)
|
||||
viewSearchList = new EditorHistoryViewSearchList();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (Event.current.type == EventType.Layout)
|
||||
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);
|
||||
|
||||
viewTools.Initialize();
|
||||
viewTools.Draw(this, rectTools, styles);
|
||||
|
||||
viewSearchList.Initialize();
|
||||
viewSearchList.Draw(this, rectList, styles);
|
||||
|
||||
HandleClickEvent();
|
||||
}
|
||||
|
||||
private void HandleClickEvent()
|
||||
{
|
||||
if (!HistoryGUIUtility.isClicked)
|
||||
return;
|
||||
|
||||
HistoryList historyList = HistoryUtility.GetHistoryList();
|
||||
Object obj = historyList.GetObject(HistoryGUIUtility.currentEntry);
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
HistoryListPostProcess.IgnoreNextSelectionChange();
|
||||
Selection.activeObject = obj;
|
||||
EditorGUIUtility.PingObject(obj);
|
||||
}
|
||||
|
||||
HistoryGUIUtility.Used();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/History/Window/EditorHistoryWindow.cs.meta
Normal file
11
Editor/History/Window/EditorHistoryWindow.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e561aeb312d93340b9abb76f0f65f22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor/History/Window/Styles.meta
Normal file
8
Editor/History/Window/Styles.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bcfcc9f9ab909284384fa64c41070bba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Editor/History/Window/Styles/Styles.cs
Normal file
32
Editor/History/Window/Styles/Styles.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor.History
|
||||
{
|
||||
internal sealed class Styles
|
||||
{
|
||||
public GUIStyle toolbox;
|
||||
|
||||
public GUIStyle entry;
|
||||
public GUIStyle invalidEntry;
|
||||
|
||||
private GUISkin skin;
|
||||
|
||||
public void Initialize(GUISkin skin)
|
||||
{
|
||||
if (this.skin == skin)
|
||||
return;
|
||||
|
||||
this.skin = skin;
|
||||
toolbox = new GUIStyle(skin.box);
|
||||
|
||||
entry = new GUIStyle(skin.label);
|
||||
entry.hover.textColor = entry.onHover.textColor = Color.white;
|
||||
entry.active.textColor = entry.onActive.textColor = Color.yellow;
|
||||
|
||||
invalidEntry = new GUIStyle(entry);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/History/Window/Styles/Styles.cs.meta
Normal file
11
Editor/History/Window/Styles/Styles.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 39240bd81396c5d4dabe109523e9f8c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor/History/Window/Views.meta
Normal file
8
Editor/History/Window/Views.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f8f7454581679aa4fbc63ff14e2aecb3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Editor/History/Window/Views/AbstractEditorHistoryView.cs
Normal file
10
Editor/History/Window/Views/AbstractEditorHistoryView.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor.History
|
||||
{
|
||||
internal abstract class AbstractEditorHistoryView
|
||||
{
|
||||
public abstract void Initialize();
|
||||
public abstract void Draw(EditorHistoryWindow window, Rect rect, Styles styles);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e3d660bb77394c34884adc62cff3ac7c
|
||||
timeCreated: 1613305008
|
||||
53
Editor/History/Window/Views/EditorHistoryViewSearchList.cs
Normal file
53
Editor/History/Window/Views/EditorHistoryViewSearchList.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor.History
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class EditorHistoryViewSearchList : AbstractEditorHistoryView
|
||||
{
|
||||
[SerializeField]
|
||||
private Vector2 scrollPosition;
|
||||
|
||||
[NonSerialized]
|
||||
private HistoryList historyList;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
historyList = HistoryUtility.GetHistoryList();
|
||||
}
|
||||
|
||||
public override void Draw(EditorHistoryWindow window, Rect rect, Styles styles)
|
||||
{
|
||||
float entryHeight = EditorGUIUtility.singleLineHeight;
|
||||
float height = entryHeight * historyList.entries.Count;
|
||||
|
||||
bool isSearching = !string.IsNullOrEmpty(window.viewTools.searchStr);
|
||||
string lowerSearchStr = window.viewTools.searchStr.ToLower();
|
||||
|
||||
GUI.BeginGroup(rect);
|
||||
{
|
||||
var position = new Rect(0.0f, 0.0f, rect.width, rect.height);
|
||||
var viewRect = new Rect(0.0f, 0.0f, position.height > height ? position.width : position.width - 14.0f, height);
|
||||
var entryRect = new Rect(0.0f, 0.0f, viewRect.width, entryHeight);
|
||||
|
||||
scrollPosition = GUI.BeginScrollView(position, scrollPosition, viewRect);
|
||||
{
|
||||
for (int i = historyList.entries.Count - 1; i >= 0; i--)
|
||||
{
|
||||
HistoryList.Entry e = historyList.entries[i];
|
||||
|
||||
if (isSearching && !e.lowerName.Contains(lowerSearchStr))
|
||||
continue;
|
||||
|
||||
HistoryGUIUtility.DrawEntry(entryRect, historyList.entries[i], styles, true);
|
||||
entryRect.y += entryHeight;
|
||||
}
|
||||
}
|
||||
GUI.EndScrollView();
|
||||
}
|
||||
GUI.EndGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7b9e14bc776433a4482034c88a6c9ad5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Editor/History/Window/Views/EditorHistoryViewTools.cs
Normal file
41
Editor/History/Window/Views/EditorHistoryViewTools.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor.History
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class EditorHistoryViewTools : AbstractEditorHistoryView
|
||||
{
|
||||
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 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);
|
||||
|
||||
if (GUI.Button(r1, "Clear"))
|
||||
historyList.Clear();
|
||||
}
|
||||
GUI.EndGroup();
|
||||
}
|
||||
|
||||
public bool IsSearching()
|
||||
{
|
||||
return !string.IsNullOrEmpty(searchStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/History/Window/Views/EditorHistoryViewTools.cs.meta
Normal file
11
Editor/History/Window/Views/EditorHistoryViewTools.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cc6ff725030026948be65ba87dfb9bd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,14 +1,16 @@
|
|||
{
|
||||
"name": "com.module.navigationtool",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"displayName": "Module.NavigationTool",
|
||||
"description": "Support for navigation tools",
|
||||
"description": "Support for navigation tools, like favorites and history",
|
||||
"unity": "2019.2",
|
||||
"unityRelease": "17f1",
|
||||
"dependencies": {
|
||||
},
|
||||
"keywords": [
|
||||
"navigation"
|
||||
"navigation",
|
||||
"favorites",
|
||||
"history"
|
||||
],
|
||||
"author": {
|
||||
"name": "Anders Ejlersen",
|
||||
|
|
|
|||
Loading…
Reference in a new issue