Skip to content

Commit 52c590e

Browse files
committed
✨ 修改异常
1 parent 83c9785 commit 52c590e

File tree

7 files changed

+67
-129
lines changed

7 files changed

+67
-129
lines changed

.github/qodana.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/code_quality.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

Editor/Data/Collect/Item/AssetCollectItemEx.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public static string[] GetDisPlayNames(this IEnumerable<AssetCollectItem> collec
1414
where item.Type == EAssetCollectItemType.MainAssetCollector
1515
where !string.IsNullOrEmpty(item.CollectPath)
1616
select item.CollectPath
17-
).Distinct()
18-
.ToArray();
17+
).Distinct().
18+
ToArray();
1919
}
2020
}
21-
}
21+
}

Editor/Windows/AssetWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static T OpenPage<T>()
150150
if (!Instance)
151151
{
152152
EditorApplication.ExecuteMenuItem(MENU_WINDOW);
153-
return default;
153+
return default(T);
154154
}
155155

156156
Instance.PageIndex = Instance.Pages.IndexOf(Instance.Pages.FirstOrDefault(p => p is T));
@@ -166,4 +166,4 @@ public static bool IsOpenPage<T>()
166166

167167
#endregion
168168
}
169-
}
169+
}

Editor/Windows/Page/1AssetPage.EditCollect.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,23 @@ public static void OpenCollectItem(AssetCollectItem item)
135135
{
136136
if (item.Type == EAssetCollectItemType.MainAssetCollector)
137137
{
138+
int status;
138139
var list = AssetCollectRoot.GetOrCreate().CurrentGroup.Collectors.GetDisPlayNames();
139140
if (list.Length > 31)
140141
{
141-
AssetPageLook.DisplayCollectorsIndex = 0;
142+
status = 0;
142143
for (var i = 0; i < list.Length; i++)
144+
{
143145
if (list[i] == item.CollectPath)
144146
{
145-
AssetPageLook.DisplayCollectorsIndex = i + 1;
147+
status = i + 1;
146148
break;
147149
}
150+
}
148151
}
149152
else
150153
{
151-
var status = 1;
154+
status = 1;
152155
foreach (var collector in list)
153156
{
154157
if (collector != item.CollectPath)
@@ -157,11 +160,12 @@ public static void OpenCollectItem(AssetCollectItem item)
157160
continue;
158161
}
159162

160-
AssetPageLook.DisplayCollectorsIndex = status;
161163
break;
162164
}
163165
}
166+
164167
AssetWindow.OpenPage<AssetPageLook.Collect>();
168+
AssetPageLook.DisplayCollectorsIndex = status;
165169
return;
166170
}
167171

@@ -304,4 +308,4 @@ public void OnDrawHeader(Rect rect)
304308
EditorGUI.DropShadowLabel(rect, TempBuilder.ToString());
305309
}
306310
}
307-
}
311+
}

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

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ void IAssetPage.EventMouseDrag(in Event evt)
2929
if (Instance.ShowAssetDetail) Instance.ViewDetailList.DraggingStretch(evt, ViewRect.DragStretchType.Horizontal);
3030
}
3131

32-
bool IAssetPage.Shortcut(Event evt) =>
33-
evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad4 || evt.keyCode == KeyCode.Alpha4);
32+
bool IAssetPage.Shortcut(Event evt) => evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad4 || evt.keyCode == KeyCode.Alpha4);
3433

3534
public void Dispose()
3635
{
@@ -50,52 +49,41 @@ public void Dispose()
5049
private Dictionary<(int, int), string[]> TagDisplays;
5150
private Dictionary<(int, int), ConcurrentBag<AssetDataInfo>> DataDic;
5251

53-
public void OnDrawHeader(Rect rect)
52+
private Rect OnDrawGroup(Rect rect)
5453
{
55-
if (Data.Packages.Length == 0 ||
56-
DisplayPackages is null ||
57-
DisplayPackages.Length == 0) return;
58-
59-
var width = rect.width;
60-
rect.x = 0;
61-
rect.width = 100;
62-
63-
EditorGUI.BeginChangeCheck();
54+
using var scope = new EditorGUI.ChangeCheckScope();
6455
Data.CurrentPackageIndex = EditorGUI.Popup(rect, Data.CurrentPackageIndex, DisplayPackages, GEStyle.PreDropDown);
6556

66-
if (!Data.IsValidGroup()) return;
57+
if (!Data.IsValidGroup()) return rect;
6758

68-
var PName = DisplayPackages[Data.CurrentPackageIndex];
69-
if (!DisplayGroupNames.ContainsKey(PName))
70-
DisplayGroupNames[PName] = GetGroupDisPlayNames(Data.CurrentPackage.Groups);
59+
var package = DisplayPackages[Data.CurrentPackageIndex];
60+
if (!DisplayGroupNames.ContainsKey(package))
61+
DisplayGroupNames[package] = GetGroupDisPlayNames(Data.CurrentPackage.Groups);
7162

72-
if (Data.CurrentGroupIndex >= DisplayGroupNames[PName].Length)
73-
Data.CurrentGroupIndex = DisplayGroupNames[PName].Length - 1;
63+
if (Data.CurrentGroupIndex >= DisplayGroupNames[package].Length)
64+
Data.CurrentGroupIndex = DisplayGroupNames[package].Length - 1;
7465

7566
rect.x += rect.width;
76-
Data.CurrentGroupIndex = EditorGUI.Popup(rect, Data.CurrentGroupIndex, DisplayGroupNames[PName], GEStyle.PreDropDown);
67+
Data.CurrentGroupIndex = EditorGUI.Popup(rect, Data.CurrentGroupIndex, DisplayGroupNames[package], GEStyle.PreDropDown);
7768

78-
if (!Data.IsValidCollect())
69+
if (!Data.IsValidCollect() || !scope.changed) return rect;
70+
if (!DataDic.ContainsKey((Data.CurrentPackageIndex, Data.CurrentGroupIndex)))
71+
UpdateDataCollector(Data.CurrentPackageIndex, Data.CurrentGroupIndex);
72+
else
7973
{
80-
EditorGUI.EndChangeCheck();
81-
return;
74+
PageValues.Clear();
75+
PageValues.Add(DataDic[(Data.CurrentPackageIndex, Data.CurrentGroupIndex)]);
76+
PageValues.PageIndex = 0;
77+
TreeViewQueryAsset.Reload(PageValues);
8278
}
8379

84-
if (EditorGUI.EndChangeCheck())
85-
{
86-
if (!DataDic.ContainsKey((Data.CurrentPackageIndex, Data.CurrentGroupIndex)))
87-
UpdateDataCollector(Data.CurrentPackageIndex, Data.CurrentGroupIndex);
88-
else
89-
{
90-
PageValues.Clear();
91-
PageValues.Add(DataDic[(Data.CurrentPackageIndex, Data.CurrentGroupIndex)]);
92-
PageValues.PageIndex = 0;
93-
TreeViewQueryAsset.Reload(PageValues);
94-
}
95-
}
80+
return rect;
81+
}
9682

97-
EditorGUI.BeginChangeCheck();
98-
var collectors = CollectorDisplays[(Data.CurrentPackageIndex, Data.CurrentGroupIndex)];
83+
private Rect OnDrawCollector(Rect rect)
84+
{
85+
using var scope = new EditorGUI.ChangeCheckScope();
86+
var collectors = CollectorDisplays[(Data.CurrentPackageIndex, Data.CurrentGroupIndex)];
9987
if (collectors.Length > 0)
10088
{
10189
rect.x += rect.width;
@@ -151,18 +139,31 @@ DisplayPackages is null ||
151139
}
152140
else DisplayTagsIndex = 0;
153141

154-
if (EditorGUI.EndChangeCheck())
142+
if (!scope.changed) return rect;
143+
PageValues.Clear();
144+
lock (DataDic)
155145
{
156-
PageValues.Clear();
157-
lock (DataDic)
158-
{
159-
PageValues.Add(DataDic[(Data.CurrentPackageIndex, Data.CurrentGroupIndex)].Where(data => !FilterData(data)));
160-
}
161-
162-
PageValues.PageIndex = 0;
163-
TreeViewQueryAsset.Reload();
146+
PageValues.Add(DataDic[(Data.CurrentPackageIndex, Data.CurrentGroupIndex)].Where(data => !FilterData(data)));
164147
}
165148

149+
PageValues.PageIndex = 0;
150+
TreeViewQueryAsset.Reload();
151+
152+
return rect;
153+
}
154+
155+
public void OnDrawHeader(Rect rect)
156+
{
157+
if (Data.Packages.Length == 0 ||
158+
DisplayPackages is null ||
159+
DisplayPackages.Length == 0) return;
160+
161+
var width = rect.width;
162+
rect.x = 0;
163+
rect.width = 100;
164+
rect = OnDrawGroup(rect);
165+
rect = OnDrawCollector(rect);
166+
166167
rect.x += rect.width + 3;
167168
rect.width = width - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190);
168169
SearchAssetText(rect);
@@ -173,6 +174,7 @@ DisplayPackages is null ||
173174

174175
rect.x = width - 30;
175176
rect.width = 30;
177+
176178
if (GUI.Button(rect, Instance.GC_REFRESH, GEStyle.TEtoolbarbutton))
177179
{
178180
Instance.SelectAsset = null;
@@ -346,4 +348,4 @@ public void OnDrawContent(Rect rect)
346348
}
347349
}
348350
}
349-
}
351+
}

Editor/Windows/Page/AssetPage.Look.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public partial class AssetPageLook
3737
private static string[] DisplayCollectors; // 列表:收集器
3838
private static string[] DisplayTypes; // 列表:类型
3939

40-
public static int DisplayTypeIndex; // 当前选择包类型索引
41-
public static int DisplayCollectorsIndex = -1; // 当前选择收集器索引
42-
public static int DisplayTagsIndex; // 当前标签列表索引
40+
public static int DisplayTypeIndex; // 当前选择包类型索引
41+
public static int DisplayCollectorsIndex { get; set; } = -1; // 当前选择收集器索引
42+
public static int DisplayTagsIndex; // 当前标签列表索引
4343

4444
private readonly GUIContent GC_CLEAR;
4545
private readonly GUIContent GC_DEL;
@@ -615,10 +615,7 @@ private void OnDrawPageSetting(Rect rect)
615615
private static string[] GetGroupDisPlayNames(ICollection<AssetCollectGroup> groups)
616616
{
617617
var page = groups.Count > 15;
618-
return groups.Select(t => t.Name)
619-
.Where(groupName => !string.IsNullOrEmpty(groupName))
620-
.Select(groupName => page ? string.Concat(char.ToUpper(groupName[0]), '/', groupName) : groupName)
621-
.ToArray();
618+
return groups.Select(t => t.Name).Where(groupName => !string.IsNullOrEmpty(groupName)).Select(groupName => page ? string.Concat(char.ToUpper(groupName[0]), '/', groupName) : groupName).ToArray();
622619
}
623620

624621
private static string[] GetCollectorDisPlayNames(IList<string> collectors)
@@ -641,4 +638,4 @@ private static string[] GetCollectorDisPlayNames(IList<string> collectors)
641638
return collectors.ToArray();
642639
}
643640
}
644-
}
641+
}

0 commit comments

Comments
 (0)