diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index 4473e2eb..dd08ea3c 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -14,10 +14,15 @@ namespace YooAsset.Editor [MenuItem("YooAsset/AssetBundle Collector", false, 101)] public static void OpenWindow() { - AssetBundleCollectorWindow window = GetWindow("AssetBundle Collector", true, WindowsDefine.DockedWindowTypes); + AssetBundleCollectorWindow window = + GetWindow("AssetBundle Collector", true, WindowsDefine.DockedWindowTypes); window.minSize = new Vector2(800, 600); } + private string _lowerSearchKey = string.Empty; + + private ToolbarSearchField _searchField; + private Button _saveButton; private List _collectorTypeList; private List _activeRuleList; @@ -62,8 +67,7 @@ namespace YooAsset.Editor private int _lastModifyGroupIndex = 0; private bool _showGlobalSettings = false; private bool _showPackageSettings = false; - - + public void CreateGUI() { try @@ -89,6 +93,9 @@ namespace YooAsset.Editor visualAsset.CloneTree(root); + _searchField = root.Q("SearchField"); + _searchField.RegisterValueChangedCallback(OnSearchFieldValueChanged); + // 警示栏 _helpBoxContainer = root.Q("HelpBoxContainer"); @@ -358,6 +365,14 @@ namespace YooAsset.Editor Debug.LogError(e.ToString()); } } + + private void OnSearchFieldValueChanged(ChangeEvent evt) + { + _lowerSearchKey = evt.newValue.ToLower(); + + RefreshWindow(); + } + public void OnEnable() { Undo.undoRedoPerformed += RefreshWindow; @@ -400,6 +415,7 @@ namespace YooAsset.Editor FillPackageViewData(); RefreshSettings(); } + private void FixBtn_clicked() { AssetBundleCollectorSettingData.FixFile(); @@ -450,6 +466,18 @@ namespace YooAsset.Editor else return ruleDisplayName.ClassName; } + + private void ShowSearchBorder(VisualElement element) + { + element.style.borderBottomColor = new Color(0.7f,0,0,1); + element.style.borderBottomWidth = 1; + } + + private void ClearBorder(VisualElement element) + { + element.style.borderBottomColor = Color.white; + element.style.borderBottomWidth = 0; + } // 设置栏相关 private void RefreshSettings() @@ -516,6 +544,13 @@ namespace YooAsset.Editor #if UNITY_2020_3_OR_NEWER _helpBoxContainer.Clear(); + if (string.IsNullOrWhiteSpace(_lowerSearchKey) == false) + { + string tips = "Currently in search mode"; + var helpBox = new HelpBox(tips, HelpBoxMessageType.Error); + _helpBoxContainer.Add(helpBox); + } + if (_enableAddressableToogle.value && _locationToLowerToogle.value) { string tips = "The [Enable Addressable] option and [Location To Lower] option cannot be enabled at the same time."; @@ -542,7 +577,69 @@ namespace YooAsset.Editor { _packageListView.Clear(); _packageListView.ClearSelection(); - _packageListView.itemsSource = AssetBundleCollectorSettingData.Setting.Packages; + + List packages = null; + + if (string.IsNullOrWhiteSpace(_lowerSearchKey)) + { + packages = AssetBundleCollectorSettingData.Setting.Packages; + } + else + { + packages = new List(); + + foreach (var package in AssetBundleCollectorSettingData.Setting.Packages) + { + //检查packageName + if (package.PackageName.ToLower().Contains(_lowerSearchKey)) + { + packages.Add(package); + continue; + } + + //检查Groups和GroupAssetTags + foreach (var group in package.Groups) + { + if (group.GroupName.ToLower().Contains(_lowerSearchKey)) + { + packages.Add(package); + break; + } + + if (group.AssetTags.ToLower().Contains(_lowerSearchKey)) + { + packages.Add(package); + break; + } + + var needAdd = false; + + //检查Collectors和tags + foreach (var collector in group.Collectors) + { + if (collector.CollectPath.ToLower().Contains(_lowerSearchKey)) + { + needAdd = true; + break; + } + + if (collector.AssetTags.ToLower().Contains(_lowerSearchKey)) + { + needAdd = true; + break; + } + } + + if (needAdd) + { + packages.Add(package); + break; + } + } + } + } + + _packageListView.itemsSource = packages; _packageListView.Rebuild(); if (_lastModifyPackageIndex >= 0 && _lastModifyPackageIndex < _packageListView.itemsSource.Count) @@ -550,6 +647,7 @@ namespace YooAsset.Editor _packageListView.selectedIndex = _lastModifyPackageIndex; } } + private VisualElement MakePackageListViewItem() { VisualElement element = new VisualElement(); @@ -567,13 +665,26 @@ namespace YooAsset.Editor } private void BindPackageListViewItem(VisualElement element, int index) { - var package = AssetBundleCollectorSettingData.Setting.Packages[index]; + var package = _packageListView.itemsSource[index] as AssetBundleCollectorPackage; var textField1 = element.Q