优化代码结构

This commit is contained in:
邬春鹏
2025-06-09 16:06:12 +08:00
parent 31c79f3f84
commit ae087453d9

View File

@@ -68,8 +68,6 @@ namespace YooAsset.Editor
private bool _showGlobalSettings = false; private bool _showGlobalSettings = false;
private bool _showPackageSettings = false; private bool _showPackageSettings = false;
private List<AssetBundleCollectorGroup> _displayGroupList;
public void CreateGUI() public void CreateGUI()
{ {
try try
@@ -732,19 +730,21 @@ namespace YooAsset.Editor
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage; var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage == null) if (selectPackage == null)
return; return;
List<AssetBundleCollectorGroup> displayGroupList = null;
if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false) if(string.IsNullOrWhiteSpace(_lowerSearchKey) == false)
{ {
_displayGroupList = new List<AssetBundleCollectorGroup>(); displayGroupList = new List<AssetBundleCollectorGroup>();
foreach(var group in selectPackage.Groups) foreach(var group in selectPackage.Groups)
{ {
if(group.GroupName.ToLower().Contains(_lowerSearchKey)) if(group.GroupName.ToLower().Contains(_lowerSearchKey))
{ {
_displayGroupList.Add(group); displayGroupList.Add(group);
} }
else if(group.AssetTags.ToLower().Contains(_lowerSearchKey)) else if(group.AssetTags.ToLower().Contains(_lowerSearchKey))
{ {
_displayGroupList.Add(group); displayGroupList.Add(group);
} }
else else
{ {
@@ -752,13 +752,13 @@ namespace YooAsset.Editor
{ {
if(collector.CollectPath.ToLower().Contains(_lowerSearchKey)) if(collector.CollectPath.ToLower().Contains(_lowerSearchKey))
{ {
_displayGroupList.Add(group); displayGroupList.Add(group);
break; break;
} }
if(collector.AssetTags.ToLower().Contains(_lowerSearchKey)) if(collector.AssetTags.ToLower().Contains(_lowerSearchKey))
{ {
_displayGroupList.Add(group); displayGroupList.Add(group);
break; break;
} }
} }
@@ -767,12 +767,12 @@ namespace YooAsset.Editor
} }
else else
{ {
_displayGroupList = selectPackage.Groups; displayGroupList = selectPackage.Groups;
} }
_groupListView.Clear(); _groupListView.Clear();
_groupListView.ClearSelection(); _groupListView.ClearSelection();
_groupListView.itemsSource = _displayGroupList; _groupListView.itemsSource = displayGroupList;
_groupListView.Rebuild(); _groupListView.Rebuild();
if (_lastModifyGroupIndex >= 0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count) if (_lastModifyGroupIndex >= 0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count)
@@ -801,7 +801,7 @@ namespace YooAsset.Editor
if (selectPackage == null) if (selectPackage == null)
return; return;
var group = _displayGroupList[index]; var group = _groupListView.itemsSource[index] as AssetBundleCollectorGroup;
var textField1 = element.Q<Label>("Label1"); var textField1 = element.Q<Label>("Label1");
textField1.text = group.GroupName; textField1.text = group.GroupName;