0.1.0: Added favorites window
This commit is contained in:
parent
80499f0a7e
commit
dea60c6e4a
37 changed files with 1129 additions and 0 deletions
10
Editor/Favorites/Window/Views/AbstractEditorFavoritesView.cs
Normal file
10
Editor/Favorites/Window/Views/AbstractEditorFavoritesView.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
{
|
||||
internal abstract class AbstractEditorFavoritesView
|
||||
{
|
||||
public abstract void Initialize();
|
||||
public abstract void Draw(EditorFavoritesWindow window, Rect rect, Styles styles);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d16482b17fb430fa905dea21ec2fdab
|
||||
timeCreated: 1613211130
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class EditorFavoritesViewSearchList : AbstractEditorFavoritesView
|
||||
{
|
||||
[SerializeField]
|
||||
private Vector2 scrollPosition;
|
||||
|
||||
[NonSerialized]
|
||||
private Favorites favorites;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
favorites = FavoritesUtility.GetFavorites();
|
||||
}
|
||||
|
||||
public override void Draw(EditorFavoritesWindow window, Rect rect, Styles styles)
|
||||
{
|
||||
float entryHeight = EditorGUIUtility.singleLineHeight;
|
||||
float height = entryHeight * favorites.entries.Count;
|
||||
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 (var i = 0; i < favorites.entries.Count; i++)
|
||||
{
|
||||
Favorites.Entry e = favorites.entries[i];
|
||||
|
||||
if (!e.isAsset || !e.lowerName.Contains(lowerSearchStr))
|
||||
continue;
|
||||
|
||||
FavoritesGUIUtility.DrawEntry(entryRect, favorites.entries[i], styles, true);
|
||||
entryRect.y += entryHeight;
|
||||
}
|
||||
}
|
||||
GUI.EndScrollView();
|
||||
}
|
||||
GUI.EndGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 65d3b26a5050438c8d995b3c383c474f
|
||||
timeCreated: 1613211189
|
||||
38
Editor/Favorites/Window/Views/EditorFavoritesViewTools.cs
Normal file
38
Editor/Favorites/Window/Views/EditorFavoritesViewTools.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class EditorFavoritesViewTools : AbstractEditorFavoritesView
|
||||
{
|
||||
public string searchStr;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Draw(EditorFavoritesWindow window, Rect rect, Styles styles)
|
||||
{
|
||||
float dim = rect.height;
|
||||
|
||||
GUI.BeginGroup(rect, styles.toolbox);
|
||||
{
|
||||
var r0 = new Rect(0.0f, 0.0f, rect.width - dim, dim);
|
||||
var r1 = new Rect(rect.width - r0.height, 0.0f, dim, dim);
|
||||
|
||||
searchStr = EditorGUI.TextField(r0, searchStr);
|
||||
|
||||
if (GUI.Button(r1, "+", styles.buttonAddFolder))
|
||||
EditorFavoritesPopupWindowAddFolder.Show(new Vector2(r1.xMax, dim), null);
|
||||
}
|
||||
GUI.EndGroup();
|
||||
}
|
||||
|
||||
public bool IsSearching()
|
||||
{
|
||||
return !string.IsNullOrEmpty(searchStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b597a5bc0de34d96accec02ef9cb80ed
|
||||
timeCreated: 1613211779
|
||||
61
Editor/Favorites/Window/Views/EditorFavoritesViewTreeList.cs
Normal file
61
Editor/Favorites/Window/Views/EditorFavoritesViewTreeList.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.NavigationTool.Editor
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class EditorFavoritesViewTreeList : AbstractEditorFavoritesView
|
||||
{
|
||||
[SerializeField]
|
||||
private Vector2 scrollPosition;
|
||||
|
||||
[NonSerialized]
|
||||
private Favorites favorites;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
favorites = FavoritesUtility.GetFavorites();
|
||||
}
|
||||
|
||||
public override void Draw(EditorFavoritesWindow window, Rect rect, Styles styles)
|
||||
{
|
||||
float entryHeight = EditorGUIUtility.singleLineHeight;
|
||||
float height = entryHeight * favorites.entries.Count;
|
||||
|
||||
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 (var i = 0; i < favorites.entries.Count; i++)
|
||||
{
|
||||
Favorites.Entry e = favorites.entries[i];
|
||||
|
||||
if (e.indentLevel == 0)
|
||||
DrawEntry(e, ref entryRect, entryHeight, styles);
|
||||
}
|
||||
}
|
||||
GUI.EndScrollView();
|
||||
}
|
||||
GUI.EndGroup();
|
||||
}
|
||||
|
||||
private void DrawEntry(Favorites.Entry entry, ref Rect entryRect, float entryHeight, Styles styles)
|
||||
{
|
||||
FavoritesGUIUtility.DrawEntry(entryRect, entry, styles);
|
||||
entryRect.y += entryHeight;
|
||||
|
||||
if (entry.isAsset || !entry.expanded)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < entry.children.Count; i++)
|
||||
{
|
||||
DrawEntry(entry.children[i].entry, ref entryRect, entryHeight, styles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eb65c37d7ed60d14daa08e98eb9ee334
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue