diff --git a/.github/README.md b/.github/README.md index 594952c2..f66d74dc 100644 --- a/.github/README.md +++ b/.github/README.md @@ -14,6 +14,7 @@

+

## ⚙ 安装 @@ -131,4 +132,4 @@ - **谢谢您选择我们的扩展包。** - **如果此软件包对您有所帮助。** -- **请考虑通过添加⭐来表示支持。** +- **请考虑通过添加⭐来表示支持。** \ No newline at end of file diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 00000000..f9b47074 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,13 @@ +name: workflow for Codecov +on: [push] +jobs: + run: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@main + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true # optional (default = false) + token: ${{ secrets.CODECOV_TOKEN }} # required + verbose: true # optional (default = false) \ No newline at end of file diff --git a/Editor/Interface/AssetInfoData.cs b/Editor/Interface/AssetInfoData.cs index 88581b09..10f63e99 100644 --- a/Editor/Interface/AssetInfoData.cs +++ b/Editor/Interface/AssetInfoData.cs @@ -282,7 +282,7 @@ public string Type private long _size; [NonSerialized] - private string _type; + internal string _type; [NonSerialized] private string _guid; diff --git a/Editor/Windows/Page/2AssetPage.EditConfig.cs b/Editor/Windows/Page/2AssetPage.EditConfig.cs index 110117dc..8c596402 100644 --- a/Editor/Windows/Page/2AssetPage.EditConfig.cs +++ b/Editor/Windows/Page/2AssetPage.EditConfig.cs @@ -18,9 +18,9 @@ internal class AssetPageEditConfig : IAssetPage public AssetPageEditConfig() { GC_Select = GEContent.NewSetting("ic_Eyes", "选择资源配置文件"); - GC_SAVE = GEContent.NewBuiltin("d_SaveAs", "保存"); - Data = AssetCollectRoot.GetOrCreate(); - Config = ASConfig.GetOrCreate(); + GC_SAVE = GEContent.NewBuiltin("d_SaveAs", "保存"); + Data = AssetCollectRoot.GetOrCreate(); + Config = ASConfig.GetOrCreate(); ViewConfig = new ViewRect(550, 1) @@ -35,9 +35,9 @@ public AssetPageEditConfig() public void Dispose() { - Data = null; - Config = null; - GC_SAVE = null; + Data = null; + Config = null; + GC_SAVE = null; GC_Select = null; } @@ -299,116 +299,115 @@ private void OnDrawASConfig(Rect rect) cell.y += cell.height; cell.x = rect.x + 10; cell.width = rect.width - cell.x; - GUI.Label(cell, + GUI.Label(cell, string.Format("运行时 : {0}/{1}", #if UNITY_ANDROID - $"运行时 : Application.persistentDataPath/{Config.RuntimeRootDirectory}" + "Application.persistentDataPath" #elif UNITY_STANDALONE_WIN - $"运行时 : Application.streamingAssetsPath/{Config.RuntimeRootDirectory}" + "Application.streamingAssetsPath" #elif UNITY_IPHONE || UNITY_IOS - $"运行时 : Application.persistentDataPath/{Config.RuntimeRootDirectory}" + "Application.persistentDataPath" #elif UNITY_WEBGL - $"运行时 : Application.persistentDataPath/{Config.RuntimeRootDirectory}" + "Application.persistentDataPath" +#else + "Not Support" #endif - , GEStyle.HeaderLabel); + , Config.RuntimeRootDirectory), GEStyle.HeaderLabel); } - - if (string.IsNullOrEmpty(Config.RuntimeRootDirectory)) GUI.enabled = false; - - switch (Config.ASMode) + using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(Config.RuntimeRootDirectory))) { - case EASMode.Remote: + switch (Config.ASMode) { + case EASMode.Remote: { - cell.y += cell.height; - cell.x = rect.x + 10; - cell.width = 150; - GUI.Label(cell, "远端资源地址", GEStyle.HeaderLabel); - } - using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(Config.URL))) - { - cell.width = 100; - cell.x = rect.width - cell.width; - if (GUI.Button(cell, "跳转首包清单", GEStyle.toolbarbutton)) { - AssetWindow.OpenPage(); - GUI.FocusControl(null); + cell.y += cell.height; + cell.x = rect.x + 10; + cell.width = 150; + GUI.Label(cell, "远端资源地址", GEStyle.HeaderLabel); + } + using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(Config.URL))) + { + cell.width = 100; + cell.x = rect.width - cell.width; + if (GUI.Button(cell, "跳转首包清单", GEStyle.toolbarbutton)) + { + AssetWindow.OpenPage(); + GUI.FocusControl(null); + } + + cell.width = 100; + cell.x -= cell.width; + if (GUI.Button(cell, "打开远端网页", GEStyle.toolbarbutton)) + { + Application.OpenURL(Config.URL); + GUI.FocusControl(null); + } } - cell.width = 100; - cell.x -= cell.width; - if (GUI.Button(cell, "打开远端网页", GEStyle.toolbarbutton)) { - Application.OpenURL(Config.URL); - GUI.FocusControl(null); + cell.y += cell.height; + cell.x = rect.x + 10; + cell.width = rect.width - cell.x; + cell.height = 50; + Config.URL = GUI.TextArea(cell, Config.URL); } - } - { - cell.y += cell.height; - cell.x = rect.x + 10; - cell.width = rect.width - cell.x; - cell.height = 50; - Config.URL = GUI.TextArea(cell, Config.URL); - } + { + cell.y += cell.height; + cell.x = rect.x + 10; + cell.width = 150; + cell.height = 20; + GUI.Label(cell, "下载失败尝试次数", GEStyle.HeaderLabel); + cell.x += cell.width; + cell.width = rect.width - cell.x; + Config.DownloadFailedTryAgain = EditorGUI.IntSlider(cell, Config.DownloadFailedTryAgain, 3, 36); + } - { - cell.y += cell.height; - cell.x = rect.x + 10; - cell.width = 150; - cell.height = 20; - GUI.Label(cell, "下载失败尝试次数", GEStyle.HeaderLabel); - cell.x += cell.width; - cell.width = rect.width - cell.x; - Config.DownloadFailedTryAgain = EditorGUI.IntSlider(cell, Config.DownloadFailedTryAgain, 3, 36); - } + { + cell.y += cell.height; + cell.x = rect.x + 10; + cell.width = 150; + GUI.Label(cell, "资源加载的最大数量", GEStyle.HeaderLabel); + cell.x += cell.width; + cell.width = rect.width - cell.x; + Config.LoadingMaxTimeSlice = EditorGUI.IntSlider(cell, Config.LoadingMaxTimeSlice, 144, 8192); + } - { - cell.y += cell.height; - cell.x = rect.x + 10; - cell.width = 150; - GUI.Label(cell, "资源加载的最大数量", GEStyle.HeaderLabel); - cell.x += cell.width; - cell.width = rect.width - cell.x; - Config.LoadingMaxTimeSlice = EditorGUI.IntSlider(cell, Config.LoadingMaxTimeSlice, 144, 8192); - } + { + cell.y += cell.height; + cell.x = rect.x + 10; + cell.width = 150; + GUI.Label(cell, "请求超时时间", GEStyle.HeaderLabel); + cell.x += cell.width; + cell.width = rect.width - cell.x; + Config.Timeout = EditorGUI.IntSlider(cell, Config.Timeout, 3, 180); + } - { - cell.y += cell.height; - cell.x = rect.x + 10; - cell.width = 150; - GUI.Label(cell, "请求超时时间", GEStyle.HeaderLabel); - cell.x += cell.width; - cell.width = rect.width - cell.x; - Config.Timeout = EditorGUI.IntSlider(cell, Config.Timeout, 3, 180); + break; } - - if (string.IsNullOrEmpty(Config.URL)) GUI.enabled = true; - break; - } - default: - using (new EditorGUI.DisabledGroupScope(false)) - { - cell.y += cell.height; - cell.x = rect.x + 10; - cell.width = 150; - GUI.Label(cell, "资源包配置", GEStyle.HeaderLabel); - foreach (var config in Config.Packages) + default: + using (new EditorGUI.DisabledGroupScope(true)) { cell.y += cell.height; cell.x = rect.x + 10; - cell.width = rect.width - 20 - cell.x; - GUI.Label(cell, config.Name, GEStyle.HeaderLabel); - - cell.x += cell.width; - cell.width = 20; - config.IsDefault = GUI.Toggle(cell, config.IsDefault, ""); + cell.width = 150; + GUI.Label(cell, "资源包配置", GEStyle.HeaderLabel); + foreach (var config in Config.Packages) + { + cell.y += cell.height; + cell.x = rect.x + 10; + cell.width = rect.width - 20 - cell.x; + GUI.Label(cell, config.Name, GEStyle.HeaderLabel); + + cell.x += cell.width; + cell.width = 20; + config.IsDefault = GUI.Toggle(cell, config.IsDefault, ""); + } } - } - break; + break; + } } - - if (string.IsNullOrEmpty(Config.RuntimeRootDirectory)) GUI.enabled = true; } } } \ No newline at end of file diff --git a/Editor/Windows/Page/4AssetPage.LookCollect.cs b/Editor/Windows/Page/4AssetPage.LookCollect.cs index 0fe11c7e..c5a695d4 100644 --- a/Editor/Windows/Page/4AssetPage.LookCollect.cs +++ b/Editor/Windows/Page/4AssetPage.LookCollect.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; +using Unity.Collections; +using Unity.Jobs; +using Unity.Jobs.LowLevel.Unsafe; using UnityEditor; using UnityEngine; @@ -163,18 +166,8 @@ DisplayPackages is null || } rect.x += rect.width + 3; - rect.width = width - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190); - TreeViewQueryAsset.searchString = DataDic[(Data.CurrentPackageIndex, Data.CurrentGroupIndex)].Count > 300 - ? EditorGUI.DelayedTextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField) - : EditorGUI.TextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField); - - rect.x += rect.width; - rect.width = 30; - if (GUI.Button(rect, Instance.GC_CLEAR, GEStyle.TEtoolbarbutton)) - { - GUI.FocusControl(null); - TreeViewQueryAsset.searchString = string.Empty; - } + rect.width = width - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190); + SearchAssetText(rect); rect.x += rect.width; rect.width = 190; @@ -270,6 +263,7 @@ private bool FilterData(AssetDataInfo data) public void UpdateData() { + TreeViewQueryAsset.searchString = string.Empty; GUI.FocusControl(null); if (!Data.IsValidCollect()) return; diff --git a/Editor/Windows/Page/5AssetPage.LookTags.cs b/Editor/Windows/Page/5AssetPage.LookTags.cs index 2fadd32d..850df697 100644 --- a/Editor/Windows/Page/5AssetPage.LookTags.cs +++ b/Editor/Windows/Page/5AssetPage.LookTags.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using UnityEditor; +using UnityEditor.IMGUI.Controls; using UnityEngine; namespace AIO.UEditor @@ -28,7 +29,7 @@ void IAssetPage.EventMouseDrag(in Event evt) } bool IAssetPage.Shortcut(Event evt) => - evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad6 || evt.keyCode == KeyCode.Alpha6); + evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad5 || evt.keyCode == KeyCode.Alpha5); public void Dispose() { DisplayPackages = null; } @@ -80,27 +81,22 @@ public void OnDrawHeader(Rect rect) if (EditorGUI.EndChangeCheck()) { - PageValues.Clear(); - PageValues.Add(Values.Where(data => !FilterData(data))); - PageValues.PageIndex = 0; + lock (PageValues) + { + PageValues.Clear(); + PageValues.Add(Values.Where(data => !FilterData(data))); + PageValues.PageIndex = 0; + } + TreeViewQueryAsset.ReloadAndSelect(0); } - rect.x += rect.width + 3; - rect.width = width - 30 - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190); - TreeViewQueryAsset.searchString = Values.Count > 300 - ? EditorGUI.DelayedTextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField) - : EditorGUI.TextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField); + rect.x += rect.width + 3; - rect.x += rect.width; - rect.width = 30; - if (GUI.Button(rect, Instance.GC_CLEAR, GEStyle.TEtoolbarbutton)) - { - GUI.FocusControl(null); - TreeViewQueryAsset.searchString = string.Empty; - } + rect.width = width - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190) - 3; + SearchAssetText(rect); - rect.x += rect.width; + rect.x += rect.width + 3; rect.width = 190; Instance.OnDrawPageSetting(rect); @@ -175,11 +171,15 @@ public void OnDrawContent(Rect rect) public void UpdateData() { GUI.FocusControl(null); - Instance.SelectAsset = null; + Instance.SelectAsset = null; + TreeViewQueryAsset.searchString = string.Empty; + lock (PageValues) + { + PageValues.Clear(); + PageValues.PageIndex = 0; + } - PageValues.Clear(); - PageValues.PageIndex = 0; - Values.Clear(); + lock (Values) Values.Clear(); if (Data.Packages.Length == 0) return; @@ -218,11 +218,11 @@ public void UpdateData() void Collect(AssetCollectPackage package, AssetCollectGroup group, AssetCollectItem item) { item.CollectAssetAsync(package, group, toLower, hasExtension); - Values.AddRange(item.DataInfos.Values); + lock (Values) Values.AddRange(item.DataInfos.Values); if (listItems.Count != ++index) return; Runner.StartCoroutine(() => { - listTypes.AddRange(Values.Where(dataInfo => !listTypes.Contains(dataInfo.Type)).Select(dataInfo => dataInfo.Type)); + lock (Values) listTypes.AddRange(Values.Where(dataInfo => !listTypes.Contains(dataInfo.Type)).Select(dataInfo => dataInfo.Type)); Runner.StartTask(End); }); } @@ -242,7 +242,7 @@ void End() /// /// 标签模式 资源过滤器 /// - private bool FilterData(AssetDataInfo data) + private static bool FilterData(AssetDataInfo data) { var filter = 0; if (IsFilterCollectors(DisplayCollectorsIndex, data.CollectPath, DisplayCollectors)) filter++; diff --git a/Editor/Windows/Page/6AssetPage.LookFirstPackage.cs b/Editor/Windows/Page/6AssetPage.LookFirstPackage.cs index 9bd5a44a..810395ff 100644 --- a/Editor/Windows/Page/6AssetPage.LookFirstPackage.cs +++ b/Editor/Windows/Page/6AssetPage.LookFirstPackage.cs @@ -29,12 +29,13 @@ void IAssetPage.EventMouseDrag(in Event evt) } bool IAssetPage.Shortcut(Event evt) => - evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad5 || evt.keyCode == KeyCode.Alpha5); + evt.control && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Keypad6 || evt.keyCode == KeyCode.Alpha6); #endregion public void UpdateData() { + TreeViewQueryAsset.searchString = string.Empty; if (!Config.EnableSequenceRecord) return; if (Config.SequenceRecord.ExistsLocal()) Config.SequenceRecord.UpdateLocal(); UpdateDataAll(); @@ -115,17 +116,9 @@ public void OnDrawHeader(Rect rect) } } - rect.x += rect.width + 3; - rect.width = width - 30 - 30 - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190); - TreeViewQueryAsset.searchString = GUI.TextField(rect, TreeViewQueryAsset.searchString, GEStyle.SearchTextField); - - rect.x += rect.width; - rect.width = 30; - if (GUI.Button(rect, Instance.GC_CLEAR, GEStyle.TEtoolbarbutton)) - { - GUI.FocusControl(null); - TreeViewQueryAsset.searchString = string.Empty; - } + rect.x += rect.width + 3; + rect.width = width - 30 - 30 - 30 - rect.x - (PageValues.Count <= 0 ? 0 : 190); + SearchAssetText(rect); rect.x += rect.width; rect.width = 190; diff --git a/Editor/Windows/Page/AssetPage.Look.cs b/Editor/Windows/Page/AssetPage.Look.cs index 5e8f4ae1..3bd058f6 100644 --- a/Editor/Windows/Page/AssetPage.Look.cs +++ b/Editor/Windows/Page/AssetPage.Look.cs @@ -22,9 +22,10 @@ public partial class AssetPageLook #endregion - private static AssetCollectRoot Data; // 资源数据 - private static ASConfig Config; // 配置文件 - private static TreeViewQueryAsset TreeViewQueryAsset; + private static AssetCollectRoot Data; // 资源数据 + private static ASConfig Config; // 配置文件 + private static TreeViewQueryAsset TreeViewQueryAsset; + private static TreeViewDependencies TreeViewDependencies; private static PageList PageValues; // 当前页资源列表 @@ -231,7 +232,7 @@ private AssetPageLook() TreeViewQueryAsset.OnSingleSelectionChanged += OnQueryAsseChanged; } - + ControlID = GUIUtility.GetControlID(FocusType.Passive).ToString(); TreeViewDependencies = TreeViewDependencies.Create(Dependencies.Values); UpdatePageSizeMenu(); } @@ -257,6 +258,45 @@ private void UpdatePageSizeMenu() #endregion + private static string ControlID; + + private static void SearchAssetText(Rect rect) + { + rect.y += 2; + rect.height -= 2; + + using (new GUI.GroupScope(rect, GEStyle.ToolbarSeachTextField)) + { + var cell = new Rect(12, -1, rect.width, rect.height + 1); + if (!string.IsNullOrEmpty(TreeViewQueryAsset.searchString)) cell.width -= cell.x + 15; + else cell.width -= cell.x; + EditorGUIUtility.AddCursorRect(cell, MouseCursor.Text); + GUI.SetNextControlName(ControlID); + TreeViewQueryAsset.searchString = GUI.TextField(cell, TreeViewQueryAsset.searchString, GEStyle.MiniBoldLabel); + + // 按下 Ctrl + F 时,自动聚焦到搜索框 + if (Event.current != null && Event.current.keyCode == KeyCode.F && (Event.current.control || Event.current.command)) + { + Debug.Log("Focus"); + EditorGUIUtility.editingTextField = true; + GUI.FocusControl(ControlID); + Event.current.Use(); + } + + if (string.IsNullOrEmpty(TreeViewQueryAsset.searchString)) return; + + cell.width = 15; + cell.y = 0; + cell.x = rect.width - cell.width; + cell.height = rect.height; + EditorGUIUtility.AddCursorRect(cell, MouseCursor.Arrow); + if (!GUI.Button(cell, GUIContent.none, GEStyle.ToolbarSeachCancelButton)) return; + + GUI.FocusControl(null); + TreeViewQueryAsset.searchString = string.Empty; + } + } + #region IsFilter /// diff --git a/Editor/Windows/TreeViewItem/TreeViewItemQueryAsset.cs b/Editor/Windows/TreeViewItem/TreeViewItemQueryAsset.cs index 36957423..75473e2e 100644 --- a/Editor/Windows/TreeViewItem/TreeViewItemQueryAsset.cs +++ b/Editor/Windows/TreeViewItem/TreeViewItemQueryAsset.cs @@ -49,13 +49,9 @@ public TreeViewItemQueryAsset( public float GetHeight() => 22; public Rect GetRenameRect(Rect rowRect, int row) => rowRect; - bool ITVItemDraw.MatchSearch(string search) - { - if (string.IsNullOrEmpty(search)) return true; - return data.Address.Contains(search) - || data.AssetPath.Contains(search) - || data.Type.Contains(search); - } + bool ITVItemDraw.MatchSearch(string search) => (!string.IsNullOrEmpty(data.Address) && data.Address.Contains(search)) + || (!string.IsNullOrEmpty(data.AssetPath) && data.AssetPath.Contains(search)) + || (!string.IsNullOrEmpty(data.Type) && data.Type.Contains(search)); void ITVItemDraw.OnDraw(Rect cell, int col, ref RowGUIArgs args) {