0.3.0: Added history list
This commit is contained in:
parent
1e1736f94a
commit
9b73200c73
38 changed files with 662 additions and 18 deletions
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:
|
||||
Loading…
Add table
Add a link
Reference in a new issue