Compare commits

...

15 Commits

Author SHA1 Message Date
wuchunpeng777
6832eaf0c7 去掉多余的修改 2025-06-10 23:13:03 +08:00
wuchunpeng777
f78fd64ab9 去掉多余的修改 2025-06-10 23:07:52 +08:00
邬春鹏
ae087453d9 优化代码结构 2025-06-09 16:06:12 +08:00
邬春鹏
31c79f3f84 调整search模式的判定方式 2025-06-07 10:02:02 +08:00
邬春鹏
4293d70f85 提示方式改成统一用border 2025-06-06 12:57:16 +08:00
邬春鹏
6f5bc1b628 显示筛选过后的collector 2025-06-05 12:31:57 +08:00
邬春鹏
453cb26500 用border提示某些选项的匹配 2025-06-05 11:58:43 +08:00
邬春鹏
f35248c119 颜色提示优化 2025-06-05 11:49:22 +08:00
邬春鹏
830eb7c460 只显示筛选过的条目 2025-06-05 11:07:19 +08:00
邬春鹏
ce4a00ef7c 搜索文字颜色 2025-06-05 10:38:12 +08:00
邬春鹏
986a31cae2 group文字颜色 2025-06-05 09:35:18 +08:00
邬春鹏
1aecb54964 搜索文字颜色 2025-06-05 09:22:13 +08:00
邬春鹏
33ac8556ce 完善搜索逻辑 2025-06-04 18:31:44 +08:00
邬春鹏
517f133b21 提示信息和搜索时屏蔽操作按钮 2025-06-04 17:55:08 +08:00
邬春鹏
517830dbef 增加搜索框 2025-06-04 16:38:42 +08:00
2 changed files with 260 additions and 19 deletions

View File

@@ -14,10 +14,15 @@ namespace YooAsset.Editor
[MenuItem("YooAsset/AssetBundle Collector", false, 101)] [MenuItem("YooAsset/AssetBundle Collector", false, 101)]
public static void OpenWindow() public static void OpenWindow()
{ {
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("AssetBundle Collector", true, WindowsDefine.DockedWindowTypes); AssetBundleCollectorWindow window =
GetWindow<AssetBundleCollectorWindow>("AssetBundle Collector", true, WindowsDefine.DockedWindowTypes);
window.minSize = new Vector2(800, 600); window.minSize = new Vector2(800, 600);
} }
private string _lowerSearchKey = string.Empty;
private ToolbarSearchField _searchField;
private Button _saveButton; private Button _saveButton;
private List<string> _collectorTypeList; private List<string> _collectorTypeList;
private List<RuleDisplayName> _activeRuleList; private List<RuleDisplayName> _activeRuleList;
@@ -62,8 +67,7 @@ namespace YooAsset.Editor
private int _lastModifyGroupIndex = 0; private int _lastModifyGroupIndex = 0;
private bool _showGlobalSettings = false; private bool _showGlobalSettings = false;
private bool _showPackageSettings = false; private bool _showPackageSettings = false;
public void CreateGUI() public void CreateGUI()
{ {
try try
@@ -89,6 +93,9 @@ namespace YooAsset.Editor
visualAsset.CloneTree(root); visualAsset.CloneTree(root);
_searchField = root.Q<ToolbarSearchField>("SearchField");
_searchField.RegisterValueChangedCallback(OnSearchFieldValueChanged);
// 警示栏 // 警示栏
_helpBoxContainer = root.Q("HelpBoxContainer"); _helpBoxContainer = root.Q("HelpBoxContainer");
@@ -358,6 +365,14 @@ namespace YooAsset.Editor
Debug.LogError(e.ToString()); Debug.LogError(e.ToString());
} }
} }
private void OnSearchFieldValueChanged(ChangeEvent<string> evt)
{
_lowerSearchKey = evt.newValue.ToLower();
RefreshWindow();
}
public void OnEnable() public void OnEnable()
{ {
Undo.undoRedoPerformed += RefreshWindow; Undo.undoRedoPerformed += RefreshWindow;
@@ -400,6 +415,7 @@ namespace YooAsset.Editor
FillPackageViewData(); FillPackageViewData();
RefreshSettings(); RefreshSettings();
} }
private void FixBtn_clicked() private void FixBtn_clicked()
{ {
AssetBundleCollectorSettingData.FixFile(); AssetBundleCollectorSettingData.FixFile();
@@ -450,6 +466,18 @@ namespace YooAsset.Editor
else else
return ruleDisplayName.ClassName; 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() private void RefreshSettings()
@@ -516,6 +544,13 @@ namespace YooAsset.Editor
#if UNITY_2020_3_OR_NEWER #if UNITY_2020_3_OR_NEWER
_helpBoxContainer.Clear(); _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) if (_enableAddressableToogle.value && _locationToLowerToogle.value)
{ {
string tips = "The [Enable Addressable] option and [Location To Lower] option cannot be enabled at the same time."; 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.Clear();
_packageListView.ClearSelection(); _packageListView.ClearSelection();
_packageListView.itemsSource = AssetBundleCollectorSettingData.Setting.Packages;
List<AssetBundleCollectorPackage> packages = null;
if (string.IsNullOrWhiteSpace(_lowerSearchKey))
{
packages = AssetBundleCollectorSettingData.Setting.Packages;
}
else
{
packages = new List<AssetBundleCollectorPackage>();
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(); _packageListView.Rebuild();
if (_lastModifyPackageIndex >= 0 && _lastModifyPackageIndex < _packageListView.itemsSource.Count) if (_lastModifyPackageIndex >= 0 && _lastModifyPackageIndex < _packageListView.itemsSource.Count)
@@ -550,6 +647,7 @@ namespace YooAsset.Editor
_packageListView.selectedIndex = _lastModifyPackageIndex; _packageListView.selectedIndex = _lastModifyPackageIndex;
} }
} }
private VisualElement MakePackageListViewItem() private VisualElement MakePackageListViewItem()
{ {
VisualElement element = new VisualElement(); VisualElement element = new VisualElement();
@@ -567,13 +665,26 @@ namespace YooAsset.Editor
} }
private void BindPackageListViewItem(VisualElement element, int index) private void BindPackageListViewItem(VisualElement element, int index)
{ {
var package = AssetBundleCollectorSettingData.Setting.Packages[index]; var package = _packageListView.itemsSource[index] as AssetBundleCollectorPackage;
var textField1 = element.Q<Label>("Label1"); var textField1 = element.Q<Label>("Label1");
if (string.IsNullOrEmpty(package.PackageDesc)) textField1.text = package.PackageName;
textField1.text = package.PackageName;
else if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
textField1.text = $"{package.PackageName} ({package.PackageDesc})"; {
if(package.PackageName.ToLower().Contains(_lowerSearchKey))
{
ShowSearchBorder(element);
}
else
{
ClearBorder(element);
}
}
else
{
ClearBorder(element);
}
} }
private void PackageListView_onSelectionChange(IEnumerable<object> objs) private void PackageListView_onSelectionChange(IEnumerable<object> objs)
{ {
@@ -620,9 +731,48 @@ namespace YooAsset.Editor
if (selectPackage == null) if (selectPackage == null)
return; return;
List<AssetBundleCollectorGroup> displayGroupList = null;
if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
{
displayGroupList = new List<AssetBundleCollectorGroup>();
foreach(var group in selectPackage.Groups)
{
if(group.GroupName.ToLower().Contains(_lowerSearchKey))
{
displayGroupList.Add(group);
}
else if(group.AssetTags.ToLower().Contains(_lowerSearchKey))
{
displayGroupList.Add(group);
}
else
{
foreach(var collector in group.Collectors)
{
if(collector.CollectPath.ToLower().Contains(_lowerSearchKey))
{
displayGroupList.Add(group);
break;
}
if(collector.AssetTags.ToLower().Contains(_lowerSearchKey))
{
displayGroupList.Add(group);
break;
}
}
}
}
}
else
{
displayGroupList = selectPackage.Groups;
}
_groupListView.Clear(); _groupListView.Clear();
_groupListView.ClearSelection(); _groupListView.ClearSelection();
_groupListView.itemsSource = selectPackage.Groups; _groupListView.itemsSource = displayGroupList;
_groupListView.Rebuild(); _groupListView.Rebuild();
if (_lastModifyGroupIndex >= 0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count) if (_lastModifyGroupIndex >= 0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count)
@@ -651,13 +801,26 @@ namespace YooAsset.Editor
if (selectPackage == null) if (selectPackage == null)
return; return;
var group = selectPackage.Groups[index]; var group = _groupListView.itemsSource[index] as AssetBundleCollectorGroup;
var textField1 = element.Q<Label>("Label1"); var textField1 = element.Q<Label>("Label1");
if (string.IsNullOrEmpty(group.GroupDesc)) textField1.text = group.GroupName;
textField1.text = group.GroupName;
else if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
textField1.text = $"{group.GroupName} ({group.GroupDesc})"; {
if(group.GroupName.ToLower().Contains(_lowerSearchKey))
{
ShowSearchBorder(element);
}
else
{
ClearBorder(element);
}
}
else
{
ClearBorder(element);
}
// 激活状态 // 激活状态
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName); IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName);
@@ -679,8 +842,23 @@ namespace YooAsset.Editor
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName); _groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc); _groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
_groupTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags); _groupTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
FillCollectorViewData(); if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
{
if(selectGroup.AssetTags.ToLower().Contains(_lowerSearchKey))
{
ShowSearchBorder(_groupTagsTxt);
}
else
{
ClearBorder(_groupTagsTxt);
}
}
else
{
ClearBorder(_groupTagsTxt);
}
FillCollectorViewData();
} }
private void AddGroupBtn_clicked() private void AddGroupBtn_clicked()
{ {
@@ -718,6 +896,19 @@ namespace YooAsset.Editor
_collectorScrollView.Clear(); _collectorScrollView.Clear();
for (int i = 0; i < selectGroup.Collectors.Count; i++) for (int i = 0; i < selectGroup.Collectors.Count; i++)
{ {
if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
{
if(selectGroup.Collectors[i].CollectPath.ToLower().Contains(_lowerSearchKey))
{
}
else if(selectGroup.Collectors[i].AssetTags.ToLower().Contains(_lowerSearchKey))
{
}
else
{
continue;
}
}
VisualElement element = MakeCollectorListViewItem(); VisualElement element = MakeCollectorListViewItem();
BindCollectorListViewItem(element, i); BindCollectorListViewItem(element, i);
_collectorScrollView.Add(element); _collectorScrollView.Add(element);
@@ -881,11 +1072,45 @@ namespace YooAsset.Editor
// Collector Path // Collector Path
var objectField1 = element.Q<ObjectField>("ObjectField1"); var objectField1 = element.Q<ObjectField>("ObjectField1");
objectField1.SetValueWithoutNotify(collectObject); objectField1.SetValueWithoutNotify(collectObject);
objectField1.RegisterValueChangedCallback(evt =>
if (string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
{
if (collector.CollectPath.ToLower().Contains(_lowerSearchKey))
{
ShowSearchBorder(objectField1);
}
else
{
ClearBorder(objectField1);
}
}
else
{
ClearBorder(objectField1);
}
objectField1.RegisterValueChangedCallback(evt =>
{ {
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue); collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath); collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath);
objectField1.value.name = collector.CollectPath; objectField1.value.name = collector.CollectPath;
if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
{
if(collector.CollectPath.ToLower().Contains(_lowerSearchKey))
{
ShowSearchBorder(objectField1);
}
else
{
ClearBorder(objectField1);
}
}
else
{
ClearBorder(objectField1);
}
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
if (foldout.value) if (foldout.value)
{ {
@@ -970,7 +1195,22 @@ namespace YooAsset.Editor
// Tags // Tags
var textFiled1 = element.Q<TextField>("TextField1"); var textFiled1 = element.Q<TextField>("TextField1");
textFiled1.SetValueWithoutNotify(collector.AssetTags); if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
{
if(collector.AssetTags.ToLower().Contains(_lowerSearchKey))
{
ShowSearchBorder(textFiled1);
}
else
{
ClearBorder(textFiled1);
}
}
else
{
ClearBorder(textFiled1);
}
textFiled1.SetValueWithoutNotify(collector.AssetTags);
textFiled1.RegisterValueChangedCallback(evt => textFiled1.RegisterValueChangedCallback(evt =>
{ {
collector.AssetTags = evt.newValue; collector.AssetTags = evt.newValue;

View File

@@ -4,6 +4,7 @@
<ui:Button text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Fix" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="Fix" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<uie:ToolbarSearchField name="SearchField" />
</uie:Toolbar> </uie:Toolbar>
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;"> <ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" /> <ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" />