|
1 | 1 | using System;
|
| 2 | +using System.Collections.Concurrent; |
2 | 3 | using System.Collections.Generic;
|
3 | 4 | using System.Linq;
|
4 | 5 | using UnityEditor;
|
@@ -43,11 +44,11 @@ public void Dispose()
|
43 | 44 |
|
44 | 45 | #endregion
|
45 | 46 |
|
46 |
| - private Dictionary<string, string[]> DisplayGroupNames; |
47 |
| - private Dictionary<(int, int), string[]> CollectorDisplays; |
48 |
| - private Dictionary<(int, int), string[]> TypeDisplays; |
49 |
| - private Dictionary<(int, int), string[]> TagDisplays; |
50 |
| - private Dictionary<(int, int), List<AssetDataInfo>> DataDic; |
| 47 | + private Dictionary<string, string[]> DisplayGroupNames; |
| 48 | + private Dictionary<(int, int), string[]> CollectorDisplays; |
| 49 | + private Dictionary<(int, int), string[]> TypeDisplays; |
| 50 | + private Dictionary<(int, int), string[]> TagDisplays; |
| 51 | + private Dictionary<(int, int), ConcurrentBag<AssetDataInfo>> DataDic; |
51 | 52 |
|
52 | 53 | public void OnDrawHeader(Rect rect)
|
53 | 54 | {
|
@@ -193,47 +194,61 @@ private void UpdateDataCollector(int packageIndex, int groupIndex)
|
193 | 194 | || Data.Packages[i].Count <= j
|
194 | 195 | ) return;
|
195 | 196 |
|
196 |
| - var key = (i, j); |
197 |
| - DisplayGroupNames[DisplayPackages[i]] = GetGroupDisPlayNames(Data.Packages[i].Groups); |
198 |
| - TagDisplays[key] = Data.Packages[i].Groups[j].Tags; |
199 |
| - CollectorDisplays[key] = GetCollectorDisPlayNames(Data.Packages[i].Groups[j].Collectors.GetDisPlayNames()); |
| 197 | + var key = (i, j); |
| 198 | + var package = Data.Packages[i]; |
| 199 | + var group = package.Groups[j]; |
| 200 | + |
| 201 | + DisplayGroupNames[DisplayPackages[i]] = GetGroupDisPlayNames(package.Groups); |
| 202 | + TagDisplays[key] = group.Tags; |
| 203 | + CollectorDisplays[key] = GetCollectorDisPlayNames(group.Collectors.GetDisPlayNames()); |
200 | 204 | DisplayCollectorsIndex = 0;
|
201 |
| - DataDic[key] = new List<AssetDataInfo>(); |
| 205 | + DataDic[key] = new ConcurrentBag<AssetDataInfo>(); |
202 | 206 | TypeDisplays[(i, j)] = Array.Empty<string>();
|
203 | 207 |
|
204 | 208 | var toLower = Config.LoadPathToLower;
|
205 | 209 | var hasExtension = Config.HasExtension;
|
206 |
| - var listTypes = new List<string>(); |
| 210 | + var listTypes = new ConcurrentBag<string>(); |
207 | 211 |
|
208 |
| - var count = Data.Packages[i].Groups[j].Collectors.Length; |
| 212 | + var count = group.Collectors.Length; |
209 | 213 | var index = 0;
|
210 | 214 |
|
211 |
| - foreach (var item in Data.Packages[i].Groups[j].Collectors) |
| 215 | + foreach (var item in group.Collectors) |
212 | 216 | {
|
213 | 217 | if (item.AllowThread)
|
214 |
| - Runner.StartTask(() => Collect(item)); |
| 218 | + Runner.StartTask(Collect, item); |
215 | 219 | else
|
216 |
| - Runner.StartCoroutine(() => Collect(item)); |
| 220 | + Runner.StartCoroutine(Collect, item); |
217 | 221 | }
|
218 | 222 |
|
219 | 223 | TreeViewQueryAsset.Reload(PageValues);
|
220 | 224 | return;
|
221 | 225 |
|
222 | 226 | void Collect(AssetCollectItem item)
|
223 | 227 | {
|
224 |
| - item.CollectAssetAsync(Data.Packages[i], Data.Packages[i].Groups[j], toLower, hasExtension); |
225 |
| - DataDic[(i, j)].AddRange(item.DataInfos.Values); |
| 228 | + item.CollectAssetAsync(package, group, toLower, hasExtension); |
| 229 | + foreach (var variable in item.DataInfos.Values) |
| 230 | + { |
| 231 | + DataDic[(i, j)].Add(variable); |
| 232 | + } |
| 233 | + |
226 | 234 | if (count != ++index) return;
|
227 |
| - Runner.StartCoroutine(() => |
| 235 | + |
| 236 | + Runner.StartCoroutine(UpdateType, item); |
| 237 | + Runner.StartTask(End); |
| 238 | + } |
| 239 | + |
| 240 | + void UpdateType(AssetCollectItem item) |
| 241 | + { |
| 242 | + foreach (var type in item.DataInfos.Values.Select(dataInfo => dataInfo.Type)) |
228 | 243 | {
|
229 |
| - listTypes.AddRange(DataDic[(i, j)].Where(dataInfo => !listTypes.Contains(dataInfo.Type)).Select(dataInfo => dataInfo.Type)); |
230 |
| - Runner.StartTask(End); |
231 |
| - }); |
| 244 | + listTypes.Add(type); |
| 245 | + } |
| 246 | + |
| 247 | + TypeDisplays[(i, j)] = listTypes.Distinct().ToArray(); |
232 | 248 | }
|
233 | 249 |
|
234 | 250 | void End()
|
235 | 251 | {
|
236 |
| - TypeDisplays[(i, j)] = listTypes.ToArray(); |
237 | 252 | lock (PageValues)
|
238 | 253 | {
|
239 | 254 | PageValues.Add(DataDic[(i, j)].Where(data => !FilterData(data)));
|
@@ -273,7 +288,7 @@ public void UpdateData()
|
273 | 288 | if (TagDisplays is null) TagDisplays = new Dictionary<(int, int), string[]>();
|
274 | 289 | if (TypeDisplays is null) TypeDisplays = new Dictionary<(int, int), string[]>();
|
275 | 290 | if (DisplayGroupNames is null) DisplayGroupNames = new Dictionary<string, string[]>();
|
276 |
| - if (DataDic is null) DataDic = new Dictionary<(int, int), List<AssetDataInfo>>(); |
| 291 | + if (DataDic is null) DataDic = new Dictionary<(int, int), ConcurrentBag<AssetDataInfo>>(); |
277 | 292 |
|
278 | 293 | PageValues.Clear();
|
279 | 294 | PageValues.PageIndex = 0;
|
|
0 commit comments