#if UNITY_2019_4_OR_NEWER 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 AssetBundleCollectorWindow : EditorWindow { [MenuItem("YooAsset/AssetBundle Collector", false, 101)] public static void ShowExample() { AssetBundleCollectorWindow window = GetWindow("资源包收集工具", true, WindowsDefine.DockedWindowTypes); window.minSize = new Vector2(800, 600); } private Button _saveButton; private List _collectorTypeList; private List _activeRuleList; private List _addressRuleList; private List _packRuleList; private List _filterRuleList; private Toggle _showPackageToogle; private Toggle _enableAddressableToogle; private Toggle _uniqueBundleNameToogle; private Toggle _showEditorAliasToggle; private VisualElement _packageContainer; private ListView _packageListView; private TextField _packageNameTxt; private TextField _packageDescTxt; private VisualElement _groupContainer; private ListView _groupListView; private TextField _groupNameTxt; private TextField _groupDescTxt; private TextField _groupAssetTagsTxt; private VisualElement _collectorContainer; private ScrollView _collectorScrollView; private PopupField _activeRulePopupField; private int _lastModifyPackageIndex = 0; private int _lastModifyGroupIndex = 0; public void CreateGUI() { Undo.undoRedoPerformed -= RefreshWindow; Undo.undoRedoPerformed += RefreshWindow; try { _collectorTypeList = new List() { $"{nameof(ECollectorType.MainAssetCollector)}", $"{nameof(ECollectorType.StaticAssetCollector)}", $"{nameof(ECollectorType.DependAssetCollector)}" }; _activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames(); _addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames(); _packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames(); _filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames(); VisualElement root = this.rootVisualElement; // 加载布局文件 var visualAsset = UxmlLoader.LoadWindowUXML(); if (visualAsset == null) return; visualAsset.CloneTree(root); // 公共设置相关 _showPackageToogle = root.Q("ShowPackages"); _showPackageToogle.RegisterValueChangedCallback(evt => { AssetBundleCollectorSettingData.ModifyPackageView(evt.newValue); RefreshWindow(); }); _enableAddressableToogle = root.Q("EnableAddressable"); _enableAddressableToogle.RegisterValueChangedCallback(evt => { AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue); RefreshWindow(); }); _uniqueBundleNameToogle = root.Q("UniqueBundleName"); _uniqueBundleNameToogle.RegisterValueChangedCallback(evt => { AssetBundleCollectorSettingData.ModifyUniqueBundleName(evt.newValue); RefreshWindow(); }); _showEditorAliasToggle = root.Q("ShowEditorAlias"); _showEditorAliasToggle.RegisterValueChangedCallback(evt => { AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue); RefreshWindow(); }); // 配置修复按钮 var fixBtn = root.Q