Skip to content

Commit bcd0444

Browse files
committed
🪄 优化 资源搜索框
1 parent baf6605 commit bcd0444

File tree

6 files changed

+171
-152
lines changed

6 files changed

+171
-152
lines changed

Editor/Windows/Page/2AssetPage.EditConfig.cs

Lines changed: 90 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ internal class AssetPageEditConfig : IAssetPage
1818
public AssetPageEditConfig()
1919
{
2020
GC_Select = GEContent.NewSetting("ic_Eyes", "选择资源配置文件");
21-
GC_SAVE = GEContent.NewBuiltin("d_SaveAs", "保存");
22-
Data = AssetCollectRoot.GetOrCreate();
23-
Config = ASConfig.GetOrCreate();
21+
GC_SAVE = GEContent.NewBuiltin("d_SaveAs", "保存");
22+
Data = AssetCollectRoot.GetOrCreate();
23+
Config = ASConfig.GetOrCreate();
2424

2525

2626
ViewConfig = new ViewRect(550, 1)
@@ -35,9 +35,9 @@ public AssetPageEditConfig()
3535

3636
public void Dispose()
3737
{
38-
Data = null;
39-
Config = null;
40-
GC_SAVE = null;
38+
Data = null;
39+
Config = null;
40+
GC_SAVE = null;
4141
GC_Select = null;
4242
}
4343

@@ -299,116 +299,115 @@ private void OnDrawASConfig(Rect rect)
299299
cell.y += cell.height;
300300
cell.x = rect.x + 10;
301301
cell.width = rect.width - cell.x;
302-
GUI.Label(cell,
302+
GUI.Label(cell, string.Format("运行时 : {0}/{1}",
303303
#if UNITY_ANDROID
304-
$"运行时 : Application.persistentDataPath/{Config.RuntimeRootDirectory}"
304+
"Application.persistentDataPath"
305305
#elif UNITY_STANDALONE_WIN
306-
$"运行时 : Application.streamingAssetsPath/{Config.RuntimeRootDirectory}"
306+
"Application.streamingAssetsPath"
307307
#elif UNITY_IPHONE || UNITY_IOS
308-
$"运行时 : Application.persistentDataPath/{Config.RuntimeRootDirectory}"
308+
"Application.persistentDataPath"
309309
#elif UNITY_WEBGL
310-
$"运行时 : Application.persistentDataPath/{Config.RuntimeRootDirectory}"
310+
"Application.persistentDataPath"
311+
#else
312+
"Not Support"
311313
#endif
312-
, GEStyle.HeaderLabel);
314+
, Config.RuntimeRootDirectory), GEStyle.HeaderLabel);
313315
}
314-
315-
if (string.IsNullOrEmpty(Config.RuntimeRootDirectory)) GUI.enabled = false;
316-
317-
switch (Config.ASMode)
316+
using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(Config.RuntimeRootDirectory)))
318317
{
319-
case EASMode.Remote:
318+
switch (Config.ASMode)
320319
{
320+
case EASMode.Remote:
321321
{
322-
cell.y += cell.height;
323-
cell.x = rect.x + 10;
324-
cell.width = 150;
325-
GUI.Label(cell, "远端资源地址", GEStyle.HeaderLabel);
326-
}
327-
using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(Config.URL)))
328-
{
329-
cell.width = 100;
330-
cell.x = rect.width - cell.width;
331-
if (GUI.Button(cell, "跳转首包清单", GEStyle.toolbarbutton))
332322
{
333-
AssetWindow.OpenPage<AssetPageLook.FirstPackage>();
334-
GUI.FocusControl(null);
323+
cell.y += cell.height;
324+
cell.x = rect.x + 10;
325+
cell.width = 150;
326+
GUI.Label(cell, "远端资源地址", GEStyle.HeaderLabel);
327+
}
328+
using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(Config.URL)))
329+
{
330+
cell.width = 100;
331+
cell.x = rect.width - cell.width;
332+
if (GUI.Button(cell, "跳转首包清单", GEStyle.toolbarbutton))
333+
{
334+
AssetWindow.OpenPage<AssetPageLook.FirstPackage>();
335+
GUI.FocusControl(null);
336+
}
337+
338+
cell.width = 100;
339+
cell.x -= cell.width;
340+
if (GUI.Button(cell, "打开远端网页", GEStyle.toolbarbutton))
341+
{
342+
Application.OpenURL(Config.URL);
343+
GUI.FocusControl(null);
344+
}
335345
}
336346

337-
cell.width = 100;
338-
cell.x -= cell.width;
339-
if (GUI.Button(cell, "打开远端网页", GEStyle.toolbarbutton))
340347
{
341-
Application.OpenURL(Config.URL);
342-
GUI.FocusControl(null);
348+
cell.y += cell.height;
349+
cell.x = rect.x + 10;
350+
cell.width = rect.width - cell.x;
351+
cell.height = 50;
352+
Config.URL = GUI.TextArea(cell, Config.URL);
343353
}
344-
}
345354

346-
{
347-
cell.y += cell.height;
348-
cell.x = rect.x + 10;
349-
cell.width = rect.width - cell.x;
350-
cell.height = 50;
351-
Config.URL = GUI.TextArea(cell, Config.URL);
352-
}
355+
{
356+
cell.y += cell.height;
357+
cell.x = rect.x + 10;
358+
cell.width = 150;
359+
cell.height = 20;
360+
GUI.Label(cell, "下载失败尝试次数", GEStyle.HeaderLabel);
361+
cell.x += cell.width;
362+
cell.width = rect.width - cell.x;
363+
Config.DownloadFailedTryAgain = EditorGUI.IntSlider(cell, Config.DownloadFailedTryAgain, 3, 36);
364+
}
353365

354-
{
355-
cell.y += cell.height;
356-
cell.x = rect.x + 10;
357-
cell.width = 150;
358-
cell.height = 20;
359-
GUI.Label(cell, "下载失败尝试次数", GEStyle.HeaderLabel);
360-
cell.x += cell.width;
361-
cell.width = rect.width - cell.x;
362-
Config.DownloadFailedTryAgain = EditorGUI.IntSlider(cell, Config.DownloadFailedTryAgain, 3, 36);
363-
}
366+
{
367+
cell.y += cell.height;
368+
cell.x = rect.x + 10;
369+
cell.width = 150;
370+
GUI.Label(cell, "资源加载的最大数量", GEStyle.HeaderLabel);
371+
cell.x += cell.width;
372+
cell.width = rect.width - cell.x;
373+
Config.LoadingMaxTimeSlice = EditorGUI.IntSlider(cell, Config.LoadingMaxTimeSlice, 144, 8192);
374+
}
364375

365-
{
366-
cell.y += cell.height;
367-
cell.x = rect.x + 10;
368-
cell.width = 150;
369-
GUI.Label(cell, "资源加载的最大数量", GEStyle.HeaderLabel);
370-
cell.x += cell.width;
371-
cell.width = rect.width - cell.x;
372-
Config.LoadingMaxTimeSlice = EditorGUI.IntSlider(cell, Config.LoadingMaxTimeSlice, 144, 8192);
373-
}
376+
{
377+
cell.y += cell.height;
378+
cell.x = rect.x + 10;
379+
cell.width = 150;
380+
GUI.Label(cell, "请求超时时间", GEStyle.HeaderLabel);
381+
cell.x += cell.width;
382+
cell.width = rect.width - cell.x;
383+
Config.Timeout = EditorGUI.IntSlider(cell, Config.Timeout, 3, 180);
384+
}
374385

375-
{
376-
cell.y += cell.height;
377-
cell.x = rect.x + 10;
378-
cell.width = 150;
379-
GUI.Label(cell, "请求超时时间", GEStyle.HeaderLabel);
380-
cell.x += cell.width;
381-
cell.width = rect.width - cell.x;
382-
Config.Timeout = EditorGUI.IntSlider(cell, Config.Timeout, 3, 180);
386+
break;
383387
}
384-
385-
if (string.IsNullOrEmpty(Config.URL)) GUI.enabled = true;
386-
break;
387-
}
388-
default:
389-
using (new EditorGUI.DisabledGroupScope(false))
390-
{
391-
cell.y += cell.height;
392-
cell.x = rect.x + 10;
393-
cell.width = 150;
394-
GUI.Label(cell, "资源包配置", GEStyle.HeaderLabel);
395-
foreach (var config in Config.Packages)
388+
default:
389+
using (new EditorGUI.DisabledGroupScope(true))
396390
{
397391
cell.y += cell.height;
398392
cell.x = rect.x + 10;
399-
cell.width = rect.width - 20 - cell.x;
400-
GUI.Label(cell, config.Name, GEStyle.HeaderLabel);
401-
402-
cell.x += cell.width;
403-
cell.width = 20;
404-
config.IsDefault = GUI.Toggle(cell, config.IsDefault, "");
393+
cell.width = 150;
394+
GUI.Label(cell, "资源包配置", GEStyle.HeaderLabel);
395+
foreach (var config in Config.Packages)
396+
{
397+
cell.y += cell.height;
398+
cell.x = rect.x + 10;
399+
cell.width = rect.width - 20 - cell.x;
400+
GUI.Label(cell, config.Name, GEStyle.HeaderLabel);
401+
402+
cell.x += cell.width;
403+
cell.width = 20;
404+
config.IsDefault = GUI.Toggle(cell, config.IsDefault, "");
405+
}
405406
}
406-
}
407407

408-
break;
408+
break;
409+
}
409410
}
410-
411-
if (string.IsNullOrEmpty(Config.RuntimeRootDirectory)) GUI.enabled = true;
412411
}
413412
}
414413
}

Editor/Windows/Page/4AssetPage.LookCollect.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,8 @@ DisplayPackages is null ||
163163
}
164164

165165
rect.x += rect.width + 3;
166-
rect.width = width - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190);
167-
TreeViewQueryAsset.searchString = DataDic[(Data.CurrentPackageIndex, Data.CurrentGroupIndex)].Count > 300
168-
? EditorGUI.DelayedTextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField)
169-
: EditorGUI.TextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField);
170-
171-
rect.x += rect.width;
172-
rect.width = 30;
173-
if (GUI.Button(rect, Instance.GC_CLEAR, GEStyle.TEtoolbarbutton))
174-
{
175-
GUI.FocusControl(null);
176-
TreeViewQueryAsset.searchString = string.Empty;
177-
}
166+
rect.width = width - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190);
167+
SearchAssetText(rect);
178168

179169
rect.x += rect.width;
180170
rect.width = 190;
@@ -270,6 +260,7 @@ private bool FilterData(AssetDataInfo data)
270260

271261
public void UpdateData()
272262
{
263+
TreeViewQueryAsset.searchString = string.Empty;
273264
GUI.FocusControl(null);
274265
if (!Data.IsValidCollect()) return;
275266

Editor/Windows/Page/5AssetPage.LookTags.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using UnityEditor;
5+
using UnityEditor.IMGUI.Controls;
56
using UnityEngine;
67

78
namespace AIO.UEditor
@@ -28,7 +29,7 @@ void IAssetPage.EventMouseDrag(in Event evt)
2829
}
2930

3031
bool IAssetPage.Shortcut(Event evt) =>
31-
evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad6 || evt.keyCode == KeyCode.Alpha6);
32+
evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad5 || evt.keyCode == KeyCode.Alpha5);
3233

3334
public void Dispose() { DisplayPackages = null; }
3435

@@ -80,27 +81,22 @@ public void OnDrawHeader(Rect rect)
8081

8182
if (EditorGUI.EndChangeCheck())
8283
{
83-
PageValues.Clear();
84-
PageValues.Add(Values.Where(data => !FilterData(data)));
85-
PageValues.PageIndex = 0;
84+
lock (PageValues)
85+
{
86+
PageValues.Clear();
87+
PageValues.Add(Values.Where(data => !FilterData(data)));
88+
PageValues.PageIndex = 0;
89+
}
90+
8691
TreeViewQueryAsset.ReloadAndSelect(0);
8792
}
8893

89-
rect.x += rect.width + 3;
90-
rect.width = width - 30 - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190);
91-
TreeViewQueryAsset.searchString = Values.Count > 300
92-
? EditorGUI.DelayedTextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField)
93-
: EditorGUI.TextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField);
94+
rect.x += rect.width + 3;
9495

95-
rect.x += rect.width;
96-
rect.width = 30;
97-
if (GUI.Button(rect, Instance.GC_CLEAR, GEStyle.TEtoolbarbutton))
98-
{
99-
GUI.FocusControl(null);
100-
TreeViewQueryAsset.searchString = string.Empty;
101-
}
96+
rect.width = width - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190) - 3;
97+
SearchAssetText(rect);
10298

103-
rect.x += rect.width;
99+
rect.x += rect.width + 3;
104100
rect.width = 190;
105101
Instance.OnDrawPageSetting(rect);
106102

@@ -175,11 +171,15 @@ public void OnDrawContent(Rect rect)
175171
public void UpdateData()
176172
{
177173
GUI.FocusControl(null);
178-
Instance.SelectAsset = null;
174+
Instance.SelectAsset = null;
175+
TreeViewQueryAsset.searchString = string.Empty;
176+
lock (PageValues)
177+
{
178+
PageValues.Clear();
179+
PageValues.PageIndex = 0;
180+
}
179181

180-
PageValues.Clear();
181-
PageValues.PageIndex = 0;
182-
Values.Clear();
182+
lock (Values) Values.Clear();
183183

184184
if (Data.Packages.Length == 0) return;
185185

@@ -218,11 +218,11 @@ public void UpdateData()
218218
void Collect(AssetCollectPackage package, AssetCollectGroup group, AssetCollectItem item)
219219
{
220220
item.CollectAssetAsync(package, group, toLower, hasExtension);
221-
Values.AddRange(item.DataInfos.Values);
221+
lock (Values) Values.AddRange(item.DataInfos.Values);
222222
if (listItems.Count != ++index) return;
223223
Runner.StartCoroutine(() =>
224224
{
225-
listTypes.AddRange(Values.Where(dataInfo => !listTypes.Contains(dataInfo.Type)).Select(dataInfo => dataInfo.Type));
225+
lock (Values) listTypes.AddRange(Values.Where(dataInfo => !listTypes.Contains(dataInfo.Type)).Select(dataInfo => dataInfo.Type));
226226
Runner.StartTask(End);
227227
});
228228
}
@@ -242,7 +242,7 @@ void End()
242242
/// <summary>
243243
/// 标签模式 资源过滤器
244244
/// </summary>
245-
private bool FilterData(AssetDataInfo data)
245+
private static bool FilterData(AssetDataInfo data)
246246
{
247247
var filter = 0;
248248
if (IsFilterCollectors(DisplayCollectorsIndex, data.CollectPath, DisplayCollectors)) filter++;

Editor/Windows/Page/6AssetPage.LookFirstPackage.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ void IAssetPage.EventMouseDrag(in Event evt)
2929
}
3030

3131
bool IAssetPage.Shortcut(Event evt) =>
32-
evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad5 || evt.keyCode == KeyCode.Alpha5);
32+
evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad6 || evt.keyCode == KeyCode.Alpha6);
3333

3434
#endregion
3535

3636
public void UpdateData()
3737
{
38+
TreeViewQueryAsset.searchString = string.Empty;
3839
if (!Config.EnableSequenceRecord) return;
3940
if (Config.SequenceRecord.ExistsLocal()) Config.SequenceRecord.UpdateLocal();
4041
UpdateDataAll();
@@ -115,17 +116,9 @@ public void OnDrawHeader(Rect rect)
115116
}
116117
}
117118

118-
rect.x += rect.width + 3;
119-
rect.width = width - 30 - 30 - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190);
120-
TreeViewQueryAsset.searchString = GUI.TextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField);
121-
122-
rect.x += rect.width;
123-
rect.width = 30;
124-
if (GUI.Button(rect, Instance.GC_CLEAR, GEStyle.TEtoolbarbutton))
125-
{
126-
GUI.FocusControl(null);
127-
TreeViewQueryAsset.searchString = string.Empty;
128-
}
119+
rect.x += rect.width + 3;
120+
rect.width = width - 30 - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190);
121+
SearchAssetText(rect);
129122

130123
rect.x += rect.width;
131124
rect.width = 190;

0 commit comments

Comments
 (0)