using System; using System.IO; using System.Linq; using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEditor.UIElements; using UnityEngine.UIElements; namespace YooAsset.Editor { /// /// 资源收集器编辑器窗口 /// public class BundleCollectorWindow : EditorWindow { /// /// 打开资源收集器窗口 /// [MenuItem("YooAsset/Bundle Collector", false, 101)] public static void OpenWindow() { Type[] dockedTypes = EditorWindowDefine.GetDockedWindowTypes(); BundleCollectorWindow window = GetWindow("Bundle Collector", true, dockedTypes); window.minSize = new Vector2(800, 600); } private const string PlaceholderClass = "search-placeholder"; private Button _saveButton; private List _collectorTypeList; private List _groupActiveRuleList; private List _addressRuleList; private List _bundlePackRuleList; private List _assetFilterRuleList; private List _assetIgnoreRuleList; private VisualElement _helpBoxContainer; private ToolbarSearchField _searchField; private TextField _searchTextField; private Button _searchButton; private Label _searchResultLabel; private Button _globalSettingsButton; private Button _packageSettingsButton; private VisualElement _setting1Container; private Toggle _showPackageToggle; private Toggle _showEditorAliasToggle; private Toggle _uniqueBundleNameToggle; private VisualElement _setting2Container; private Toggle _enableAddressableToggle; private Toggle _supportExtensionlessToggle; private Toggle _locationToLowerToggle; private Toggle _includeAssetGUIDToggle; private Toggle _autoCollectShadersToggle; private PopupField _ignoreRulePopupField; private VisualElement _packageContainer; private ListView _packageListView; private TextField _packageNameTextField; private TextField _packageDescTextField; private VisualElement _groupContainer; private ListView _groupListView; private TextField _groupNameTextField; private TextField _groupDescTextField; private TextField _groupTagsTextField; private VisualElement _collectorContainer; private ScrollView _collectorScrollView; private PopupField _activeRulePopupField; private string _highlightAssetPath; private int _highlightCollectorIndex = -1; private int _lastModifyPackageIndex = 0; private int _lastModifyGroupIndex = 0; private bool _showGlobalSettings = false; private bool _showPackageSettings = false; /// /// 创建编辑器界面 /// public void CreateGUI() { try { _collectorTypeList = new List() { $"{nameof(ECollectorType.MainAssetCollector)}", $"{nameof(ECollectorType.StaticAssetCollector)}", $"{nameof(ECollectorType.DependAssetCollector)}" }; _groupActiveRuleList = BundleCollectorSettingData.GetGroupActiveRuleNames(); _addressRuleList = BundleCollectorSettingData.GetAddressRuleNames(); _bundlePackRuleList = BundleCollectorSettingData.GetBundlePackRuleNames(); _assetFilterRuleList = BundleCollectorSettingData.GetAssetFilterRuleNames(); _assetIgnoreRuleList = BundleCollectorSettingData.GetAssetIgnoreRuleNames(); VisualElement root = this.rootVisualElement; // 加载布局文件 var visualAsset = UxmlLoader.LoadWindowUxml(); if (visualAsset == null) return; visualAsset.CloneTree(root); // 警示栏 _helpBoxContainer = root.Q("HelpBoxContainer"); _globalSettingsButton = root.Q