diff --git a/Editor/Favorites/Enums/EManipulatingState.cs b/Editor/Favorites/Enums/EManipulatingState.cs index 3d5476a..41a475d 100644 --- a/Editor/Favorites/Enums/EManipulatingState.cs +++ b/Editor/Favorites/Enums/EManipulatingState.cs @@ -1,4 +1,4 @@ -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { public enum EManipulatingState : byte { diff --git a/Editor/Favorites/Utilities/Favorites.cs b/Editor/Favorites/Utilities/Favorites.cs index 9567d90..6434371 100644 --- a/Editor/Favorites/Utilities/Favorites.cs +++ b/Editor/Favorites/Utilities/Favorites.cs @@ -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 diff --git a/Editor/Favorites/Utilities/FavoritesGUIUtility.cs b/Editor/Favorites/Utilities/FavoritesGUIUtility.cs index 43c05c7..3f0208b 100644 --- a/Editor/Favorites/Utilities/FavoritesGUIUtility.cs +++ b/Editor/Favorites/Utilities/FavoritesGUIUtility.cs @@ -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; } } diff --git a/Editor/Favorites/Utilities/FavoritesPostProcess.cs b/Editor/Favorites/Utilities/FavoritesPostProcess.cs index 8a6d4cb..de7f7cd 100644 --- a/Editor/Favorites/Utilities/FavoritesPostProcess.cs +++ b/Editor/Favorites/Utilities/FavoritesPostProcess.cs @@ -1,6 +1,6 @@ using UnityEditor; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { internal sealed class FavoritesPostProcess : AssetPostprocessor { diff --git a/Editor/Favorites/Utilities/FavoritesUtility.cs b/Editor/Favorites/Utilities/FavoritesUtility.cs index 1758957..6168550 100644 --- a/Editor/Favorites/Utilities/FavoritesUtility.cs +++ b/Editor/Favorites/Utilities/FavoritesUtility.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using UnityEditor; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { internal static class FavoritesUtility { diff --git a/Editor/Favorites/Window/EditorFavoritesPopupWindowAddFolder.cs b/Editor/Favorites/Window/EditorFavoritesPopupWindowAddFolder.cs index 3bbd21d..14172fe 100644 --- a/Editor/Favorites/Window/EditorFavoritesPopupWindowAddFolder.cs +++ b/Editor/Favorites/Window/EditorFavoritesPopupWindowAddFolder.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { internal sealed class EditorFavoritesPopupWindowAddFolder : PopupWindowContent { diff --git a/Editor/Favorites/Window/EditorFavoritesPopupWindowContextMenu.cs b/Editor/Favorites/Window/EditorFavoritesPopupWindowContextMenu.cs index 9e87276..5433d00 100644 --- a/Editor/Favorites/Window/EditorFavoritesPopupWindowContextMenu.cs +++ b/Editor/Favorites/Window/EditorFavoritesPopupWindowContextMenu.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { internal sealed class EditorFavoritesPopupWindowContextMenu : PopupWindowContent { diff --git a/Editor/Favorites/Window/EditorFavoritesPopupWindowRenameFolder.cs b/Editor/Favorites/Window/EditorFavoritesPopupWindowRenameFolder.cs index 69c294b..c0a17fe 100644 --- a/Editor/Favorites/Window/EditorFavoritesPopupWindowRenameFolder.cs +++ b/Editor/Favorites/Window/EditorFavoritesPopupWindowRenameFolder.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { internal sealed class EditorFavoritesPopupWindowRenameFolder : PopupWindowContent { diff --git a/Editor/Favorites/Window/EditorFavoritesWindow.cs b/Editor/Favorites/Window/EditorFavoritesWindow.cs index fad5551..6974d00 100644 --- a/Editor/Favorites/Window/EditorFavoritesWindow.cs +++ b/Editor/Favorites/Window/EditorFavoritesWindow.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { internal sealed class EditorFavoritesWindow : EditorWindow { diff --git a/Editor/Favorites/Window/Styles/Styles.cs b/Editor/Favorites/Window/Styles/Styles.cs index c9e726f..22103de 100644 --- a/Editor/Favorites/Window/Styles/Styles.cs +++ b/Editor/Favorites/Window/Styles/Styles.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { internal sealed class Styles { diff --git a/Editor/Favorites/Window/Views/AbstractEditorFavoritesView.cs b/Editor/Favorites/Window/Views/AbstractEditorFavoritesView.cs index 24094b8..6c4f5b2 100644 --- a/Editor/Favorites/Window/Views/AbstractEditorFavoritesView.cs +++ b/Editor/Favorites/Window/Views/AbstractEditorFavoritesView.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { internal abstract class AbstractEditorFavoritesView { diff --git a/Editor/Favorites/Window/Views/EditorFavoritesViewSearchList.cs b/Editor/Favorites/Window/Views/EditorFavoritesViewSearchList.cs index 2f90ba8..1f60444 100644 --- a/Editor/Favorites/Window/Views/EditorFavoritesViewSearchList.cs +++ b/Editor/Favorites/Window/Views/EditorFavoritesViewSearchList.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { [Serializable] internal sealed class EditorFavoritesViewSearchList : AbstractEditorFavoritesView diff --git a/Editor/Favorites/Window/Views/EditorFavoritesViewTools.cs b/Editor/Favorites/Window/Views/EditorFavoritesViewTools.cs index f1cfc57..a37100f 100644 --- a/Editor/Favorites/Window/Views/EditorFavoritesViewTools.cs +++ b/Editor/Favorites/Window/Views/EditorFavoritesViewTools.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { [Serializable] internal sealed class EditorFavoritesViewTools : AbstractEditorFavoritesView diff --git a/Editor/Favorites/Window/Views/EditorFavoritesViewTreeList.cs b/Editor/Favorites/Window/Views/EditorFavoritesViewTreeList.cs index f43f01d..ce59689 100644 --- a/Editor/Favorites/Window/Views/EditorFavoritesViewTreeList.cs +++ b/Editor/Favorites/Window/Views/EditorFavoritesViewTreeList.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace Game.NavigationTool.Editor +namespace Game.NavigationTool.Editor.Favorite { [Serializable] internal sealed class EditorFavoritesViewTreeList : AbstractEditorFavoritesView diff --git a/Editor/History.meta b/Editor/History.meta new file mode 100644 index 0000000..afbef35 --- /dev/null +++ b/Editor/History.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7bbcde81c1d70cb419a781a2ac8b3f94 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Utilities.meta b/Editor/History/Utilities.meta new file mode 100644 index 0000000..6492722 --- /dev/null +++ b/Editor/History/Utilities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6f86cbee736eef748b28697927b877b4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Utilities/HistoryGUIUtility.cs b/Editor/History/Utilities/HistoryGUIUtility.cs new file mode 100644 index 0000000..5cd11c8 --- /dev/null +++ b/Editor/History/Utilities/HistoryGUIUtility.cs @@ -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()) + return; + + var window = EditorWindow.GetWindow("History", false); + window.Repaint(); + } + } +} \ No newline at end of file diff --git a/Editor/History/Utilities/HistoryGUIUtility.cs.meta b/Editor/History/Utilities/HistoryGUIUtility.cs.meta new file mode 100644 index 0000000..6f39618 --- /dev/null +++ b/Editor/History/Utilities/HistoryGUIUtility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fd4d5beff36f41d40ac4a5a495488f8e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Utilities/HistoryList.cs b/Editor/History/Utilities/HistoryList.cs new file mode 100644 index 0000000..f71d212 --- /dev/null +++ b/Editor/History/Utilities/HistoryList.cs @@ -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 entries; + + public HistoryList() + { + entries = new List(); + 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); + } + + /// + /// Class: Entry + /// + [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); + } + } + } +} \ No newline at end of file diff --git a/Editor/History/Utilities/HistoryList.cs.meta b/Editor/History/Utilities/HistoryList.cs.meta new file mode 100644 index 0000000..0c32da0 --- /dev/null +++ b/Editor/History/Utilities/HistoryList.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a7c41592f12a4174885c183470ce5e91 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Utilities/HistoryListPostProcess.cs b/Editor/History/Utilities/HistoryListPostProcess.cs new file mode 100644 index 0000000..c528cb4 --- /dev/null +++ b/Editor/History/Utilities/HistoryListPostProcess.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/Editor/History/Utilities/HistoryListPostProcess.cs.meta b/Editor/History/Utilities/HistoryListPostProcess.cs.meta new file mode 100644 index 0000000..d428737 --- /dev/null +++ b/Editor/History/Utilities/HistoryListPostProcess.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d8bd093d38234a4f9268f2fb4fc6b80 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Utilities/HistoryUtility.cs b/Editor/History/Utilities/HistoryUtility.cs new file mode 100644 index 0000000..27dd672 --- /dev/null +++ b/Editor/History/Utilities/HistoryUtility.cs @@ -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 entries = HISTORY_LIST.entries; + + for (var i = 0; i < entries.Count; i++) + { + entries[i].Refresh(); + } + } + } +} \ No newline at end of file diff --git a/Editor/History/Utilities/HistoryUtility.cs.meta b/Editor/History/Utilities/HistoryUtility.cs.meta new file mode 100644 index 0000000..dff502a --- /dev/null +++ b/Editor/History/Utilities/HistoryUtility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4ceaae411c5d2e64b899ea234444354b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Window.meta b/Editor/History/Window.meta new file mode 100644 index 0000000..c6605ac --- /dev/null +++ b/Editor/History/Window.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0bcd27df5069d28488ed46453c10c44e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Window/EditorHistoryWindow.cs b/Editor/History/Window/EditorHistoryWindow.cs new file mode 100644 index 0000000..cfbee8e --- /dev/null +++ b/Editor/History/Window/EditorHistoryWindow.cs @@ -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(); + 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(); + } + } +} \ No newline at end of file diff --git a/Editor/History/Window/EditorHistoryWindow.cs.meta b/Editor/History/Window/EditorHistoryWindow.cs.meta new file mode 100644 index 0000000..1265e26 --- /dev/null +++ b/Editor/History/Window/EditorHistoryWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1e561aeb312d93340b9abb76f0f65f22 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Window/Styles.meta b/Editor/History/Window/Styles.meta new file mode 100644 index 0000000..7cca7c2 --- /dev/null +++ b/Editor/History/Window/Styles.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bcfcc9f9ab909284384fa64c41070bba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Window/Styles/Styles.cs b/Editor/History/Window/Styles/Styles.cs new file mode 100644 index 0000000..1e9449f --- /dev/null +++ b/Editor/History/Window/Styles/Styles.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/Editor/History/Window/Styles/Styles.cs.meta b/Editor/History/Window/Styles/Styles.cs.meta new file mode 100644 index 0000000..327af8b --- /dev/null +++ b/Editor/History/Window/Styles/Styles.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 39240bd81396c5d4dabe109523e9f8c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Window/Views.meta b/Editor/History/Window/Views.meta new file mode 100644 index 0000000..0210707 --- /dev/null +++ b/Editor/History/Window/Views.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f8f7454581679aa4fbc63ff14e2aecb3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Window/Views/AbstractEditorHistoryView.cs b/Editor/History/Window/Views/AbstractEditorHistoryView.cs new file mode 100644 index 0000000..1847091 --- /dev/null +++ b/Editor/History/Window/Views/AbstractEditorHistoryView.cs @@ -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); + } +} \ No newline at end of file diff --git a/Editor/History/Window/Views/AbstractEditorHistoryView.cs.meta b/Editor/History/Window/Views/AbstractEditorHistoryView.cs.meta new file mode 100644 index 0000000..3bdaa26 --- /dev/null +++ b/Editor/History/Window/Views/AbstractEditorHistoryView.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e3d660bb77394c34884adc62cff3ac7c +timeCreated: 1613305008 \ No newline at end of file diff --git a/Editor/History/Window/Views/EditorHistoryViewSearchList.cs b/Editor/History/Window/Views/EditorHistoryViewSearchList.cs new file mode 100644 index 0000000..c1cf84f --- /dev/null +++ b/Editor/History/Window/Views/EditorHistoryViewSearchList.cs @@ -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(); + } + } +} \ No newline at end of file diff --git a/Editor/History/Window/Views/EditorHistoryViewSearchList.cs.meta b/Editor/History/Window/Views/EditorHistoryViewSearchList.cs.meta new file mode 100644 index 0000000..52b42bd --- /dev/null +++ b/Editor/History/Window/Views/EditorHistoryViewSearchList.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7b9e14bc776433a4482034c88a6c9ad5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/History/Window/Views/EditorHistoryViewTools.cs b/Editor/History/Window/Views/EditorHistoryViewTools.cs new file mode 100644 index 0000000..b7b9ea3 --- /dev/null +++ b/Editor/History/Window/Views/EditorHistoryViewTools.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/Editor/History/Window/Views/EditorHistoryViewTools.cs.meta b/Editor/History/Window/Views/EditorHistoryViewTools.cs.meta new file mode 100644 index 0000000..9d561ea --- /dev/null +++ b/Editor/History/Window/Views/EditorHistoryViewTools.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cc6ff725030026948be65ba87dfb9bd9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json index 0d24a71..2481682 100644 --- a/package.json +++ b/package.json @@ -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",