Skip to content

Commit b63f4a6

Browse files
authored
Merge pull request #79 from AIO-GAME/1.x
1.x
2 parents 2ca3f39 + e79e526 commit b63f4a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+421
-560
lines changed

Editor/Data/AssetBuildConfig.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using AIO.UEngine;
55
using UnityEditor;
66
using UnityEngine;
7-
using UnityEngine.Serialization;
87

98
namespace AIO.UEditor
109
{

Editor/Data/Collect/Group/AssetCollectGroup.Helper.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
using System;
2-
using System.Collections;
3-
using System.Collections.Generic;
42
using System.Linq;
53
using UnityEditor;
6-
using UnityEngine.Serialization;
7-
using Object = UnityEngine.Object;
84

95
namespace AIO.UEditor
106
{
@@ -49,8 +45,7 @@ public AssetCollectItem GetByPath(string collectPath)
4945
}
5046

5147
var guid = AssetDatabase.AssetPathToGUID(collectPath);
52-
return Collectors.Where(collectItem => collectItem != null).
53-
FirstOrDefault(collectItem => collectItem.GUID == guid);
48+
return Collectors.Where(collectItem => collectItem != null).FirstOrDefault(collectItem => collectItem.GUID == guid);
5449
}
5550

5651
/// <param name="guid">收集器资源路径GUID</param>
@@ -63,8 +58,7 @@ public AssetCollectItem GetByGUID(string guid)
6358
return null;
6459
}
6560

66-
return Collectors.Where(collectItem => collectItem != null).
67-
FirstOrDefault(collectItem => collectItem.GUID == guid);
61+
return Collectors.Where(collectItem => collectItem != null).FirstOrDefault(collectItem => collectItem.GUID == guid);
6862
}
6963
}
7064
}

Editor/Data/Collect/Group/AssetCollectGroup.Interface.cs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ public void Dispose()
2525
/// <returns>迭代器</returns>
2626
public IEnumerator<AssetCollectItem> GetEnumerator()
2727
{
28-
if (Collectors is null) Collectors = Array.Empty<AssetCollectItem>();
29-
return ((IEnumerable<AssetCollectItem>)Collectors).GetEnumerator();
28+
if (Collectors is null)
29+
{
30+
Collectors = Array.Empty<AssetCollectItem>();
31+
yield break;
32+
}
33+
34+
foreach (var collect in Collectors) yield return collect;
3035
}
3136

3237
public int IndexOf(AssetCollectItem item)
@@ -50,7 +55,7 @@ public void Insert(int index, AssetCollectItem item)
5055
if (Collectors is null) Collectors = new AssetCollectItem[index + 1];
5156
if (Collectors.Length <= index)
5257
{
53-
var temp = new AssetCollectItem[index + 1];
58+
var temp = new AssetCollectItem[index + 1];
5459
for (var i = 0; i < Collectors.Length; i++) temp[i] = Collectors[i];
5560
Collectors = temp;
5661
}
@@ -64,14 +69,11 @@ public void RemoveAt(int index)
6469
Collectors = Collectors.RemoveAt(index);
6570
}
6671

67-
public void Add(AssetCollectItem item)
68-
=> Collectors = Collectors is null ? new[] { item } : Collectors.Add(item);
72+
public void Add(AssetCollectItem item) => Collectors = Collectors is null ? new[] { item } : Collectors.Add(item);
6973

70-
public void Clear()
71-
=> Collectors = Array.Empty<AssetCollectItem>();
74+
public void Clear() => Collectors = Array.Empty<AssetCollectItem>();
7275

73-
public bool Contains(AssetCollectItem item)
74-
=> IndexOf(item) != -1;
76+
public bool Contains(AssetCollectItem item) => IndexOf(item) != -1;
7577

7678
public void CopyTo(AssetCollectItem[] array, int arrayIndex)
7779
{
@@ -128,29 +130,21 @@ int IEqualityComparer<AssetCollectGroup>.GetHashCode(AssetCollectGroup obj)
128130
int ICollection<AssetCollectItem>. Count => Count;
129131
bool ICollection<AssetCollectItem>.IsReadOnly => false;
130132

131-
int IList<AssetCollectItem>.IndexOf(AssetCollectItem item)
132-
=> IndexOf(item);
133+
int IList<AssetCollectItem>.IndexOf(AssetCollectItem item) => IndexOf(item);
133134

134-
void ICollection<AssetCollectItem>.Add(AssetCollectItem item)
135-
=> Add(item);
135+
void ICollection<AssetCollectItem>.Add(AssetCollectItem item) => Add(item);
136136

137-
void ICollection<AssetCollectItem>.Clear()
138-
=> Clear();
137+
void ICollection<AssetCollectItem>.Clear() => Clear();
139138

140-
bool ICollection<AssetCollectItem>.Contains(AssetCollectItem item)
141-
=> Contains(item);
139+
bool ICollection<AssetCollectItem>.Contains(AssetCollectItem item) => Contains(item);
142140

143-
void ICollection<AssetCollectItem>.CopyTo(AssetCollectItem[] array, int arrayIndex)
144-
=> CopyTo(array, arrayIndex);
141+
void ICollection<AssetCollectItem>.CopyTo(AssetCollectItem[] array, int arrayIndex) => CopyTo(array, arrayIndex);
145142

146-
void IList<AssetCollectItem>.Insert(int index, AssetCollectItem item)
147-
=> Insert(index, item);
143+
void IList<AssetCollectItem>.Insert(int index, AssetCollectItem item) => Insert(index, item);
148144

149-
bool ICollection<AssetCollectItem>.Remove(AssetCollectItem item)
150-
=> Remove(item);
145+
bool ICollection<AssetCollectItem>.Remove(AssetCollectItem item) => Remove(item);
151146

152-
void IList<AssetCollectItem>.RemoveAt(int index)
153-
=> RemoveAt(index);
147+
void IList<AssetCollectItem>.RemoveAt(int index) => RemoveAt(index);
154148

155149
#endregion
156150
}

Editor/Data/Collect/Group/AssetCollectGroup.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43
using System.ComponentModel;
54
using System.Linq;

Editor/Data/Collect/Item/AssetCollectItem.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
5-
using AIO.UEngine;
64
using UnityEditor;
7-
using UnityEngine.Serialization;
85
using Object = UnityEngine.Object;
96

107
namespace AIO.UEditor
@@ -37,7 +34,7 @@ public sealed partial class AssetCollectItem : IDisposable, IEqualityComparer<As
3734
new Dictionary<string, AssetDataInfo>();
3835

3936
public IReadOnlyDictionary<string, AssetDataInfo> DataInfos => AssetDataInfos;
40-
37+
4138
/// <summary>
4239
/// 获取收集规则
4340
/// </summary>
@@ -303,7 +300,7 @@ private void CollectAsset(string[] tags, bool toLower, bool hasExtension)
303300
CollectPath = data.CollectPath,
304301
Package = data.PackageName,
305302
Group = data.GroupName,
306-
Tag = data.Tags
303+
Tag = data.Tags
307304
};
308305

309306
if (Directory.Exists(CollectPath)) // 判断Path是否为文件夹
@@ -360,7 +357,7 @@ public void CollectAssetAsync(
360357
AssetCollectGroup group,
361358
bool toLower,
362359
bool hasExtension,
363-
Action<Dictionary<string, AssetDataInfo>> cb = null)
360+
Action<Dictionary<string, AssetDataInfo>> cb)
364361
{
365362
AssetDataInfos.Clear();
366363
if (!IsValidate) return;

Editor/Data/Collect/Package/AssetCollectPackage.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ public string[] Tags
6262
continue;
6363
}
6464

65-
dictionary.AddRange(group.Collectors.
66-
Where(collect => !string.IsNullOrEmpty(collect.Tags)).
67-
SelectMany(collect => collect.Tags.Split(';', ' ', ','))
68-
);
65+
dictionary.AddRange(group.Collectors.Where(collect => !string.IsNullOrEmpty(collect.Tags))
66+
.SelectMany(collect => collect.Tags.Split(';', ' ', ','))
67+
);
6968
}
7069

7170
return dictionary.Distinct().ToArray();
@@ -85,7 +84,5 @@ public void Dispose()
8584
}
8685

8786
public override int GetHashCode() => (this as IEqualityComparer<AssetCollectPackage>).GetHashCode(this);
88-
89-
9087
}
9188
}

Editor/Data/Collect/Root/AssetCollectRoot.Helper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static AssetCollectRoot GetOrCreate()
126126

127127
_Instance = CreateInstance<AssetCollectRoot>();
128128
_Instance.Packages = Array.Empty<AssetCollectPackage>();
129-
AssetDatabase.CreateAsset(_Instance, "Assets/Editor/AssetCollectRoot.asset");
129+
AssetDatabase.CreateAsset(_Instance, $"Assets/Editor/{nameof(AssetCollectRoot)}.asset");
130130
AssetDatabase.SaveAssets();
131131
return _Instance;
132132
}

Editor/Data/Collect/Root/AssetCollectRoot.Interface.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void Insert(int index, AssetCollectPackage item)
4949
if (Packages is null) Packages = new AssetCollectPackage[index + 1];
5050
if (Packages.Length <= index)
5151
{
52-
var temp = new AssetCollectPackage[index + 1];
52+
var temp = new AssetCollectPackage[index + 1];
5353
for (var i = 0; i < Packages.Length; i++) temp[i] = Packages[i];
5454
Packages = temp;
5555
}
@@ -63,17 +63,13 @@ public void RemoveAt(int index)
6363
Packages = Packages.RemoveAt(index);
6464
}
6565

66-
public void Add(AssetCollectPackage item)
67-
=> Packages = Packages is null ? new[] { item } : Packages.Add(item);
66+
public void Add(AssetCollectPackage item) => Packages = Packages is null ? new[] { item } : Packages.Add(item);
6867

69-
public void Clear()
70-
=> Packages = Array.Empty<AssetCollectPackage>();
68+
public void Clear() => Packages = Array.Empty<AssetCollectPackage>();
7169

72-
public bool Contains(AssetCollectPackage item)
73-
=> IndexOf(item) != -1;
70+
public bool Contains(AssetCollectPackage item) => IndexOf(item) != -1;
7471

75-
public IEnumerator<AssetCollectPackage> GetEnumerator()
76-
=> ((IEnumerable<AssetCollectPackage>)Packages).GetEnumerator();
72+
public IEnumerator<AssetCollectPackage> GetEnumerator() => ((IEnumerable<AssetCollectPackage>)Packages).GetEnumerator();
7773

7874
public void CopyTo(AssetCollectPackage[] array, int arrayIndex)
7975
{

Editor/Data/Collect/Root/AssetCollectRoot.OnGUI.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ public AssetCollectItem CurrentCollect
2929
{
3030
get
3131
{
32-
if (CurrentGroup.Collectors is null || CurrentGroup.Collectors.Length == 0)
32+
if (CurrentGroup.Collectors is null )
3333
{
3434
CurrentGroup.Collectors = Array.Empty<AssetCollectItem>();
3535
CurrentCollectIndex = -1;
36+
return CurrentGroup.Collectors[0];
37+
}
38+
39+
if (CurrentGroup.Collectors.Length == 0)
40+
{
41+
CurrentCollectIndex = -1;
3642
return null;
3743
}
3844

@@ -48,13 +54,20 @@ public AssetCollectPackage CurrentPackage
4854
{
4955
get
5056
{
51-
if (Packages is null || Packages.Length == 0)
57+
if (Packages is null)
5258
{
5359
Packages = Array.Empty<AssetCollectPackage>();
54-
CurrentPackageIndex = 0;
60+
CurrentPackageIndex = -1;
5561
return null;
5662
}
57-
else if (CurrentPackageIndex < 0)
63+
64+
if (Packages.Length == 0)
65+
{
66+
CurrentPackageIndex = -1;
67+
return null;
68+
}
69+
70+
if (CurrentPackageIndex < 0)
5871
CurrentPackageIndex = 0;
5972
else if (Packages.Length <= CurrentPackageIndex)
6073
CurrentPackageIndex = Packages.Length - 1;
@@ -67,10 +80,17 @@ public AssetCollectGroup CurrentGroup
6780
{
6881
get
6982
{
70-
if (CurrentPackage.Groups is null || CurrentPackage.Groups.Length == 0)
83+
if (CurrentPackage is null) return null;
84+
if (CurrentPackage.Groups is null)
7185
{
7286
CurrentPackage.Groups = Array.Empty<AssetCollectGroup>();
73-
CurrentGroupIndex = 0;
87+
CurrentGroupIndex = -1;
88+
return null;
89+
}
90+
91+
if (CurrentPackage.Groups.Length == 0)
92+
{
93+
CurrentGroupIndex = -1;
7494
return null;
7595
}
7696

0 commit comments

Comments
 (0)