private void Awake() { _lastTime = EditorApplication.timeSinceStartup; // 加载提示图片 string folderPath = EditorTools.FindFolder(Application.dataPath, "ParticleProfiler"); if (string.IsNullOrEmpty(folderPath) == false) { string temp = EditorTools.AbsolutePathToAssetPath(folderPath); _texTips = AssetDatabase.LoadAssetAtPath <Texture2D>($"{temp}/GUI/tips.png"); if (_texTips == null) { Debug.LogWarning("Not found ParticleProfilerWindows tips texture."); } } else { Debug.LogWarning("Not found ParticleProfiler folder."); } // 加载测试场景 string path = EditorPrefs.GetString(PROFILER_SCENE_KEY, string.Empty); if (string.IsNullOrEmpty(path) == false) { _profilerScene = AssetDatabase.LoadAssetAtPath <SceneAsset>(path); } }
private void OnDrawDLC() { // 列表显示 EditorGUILayout.Space(); EditorGUILayout.LabelField($"[ DLC ]"); for (int i = 0; i < AssetBundleCollectorSettingData.Setting.DLCFiles.Count; i++) { string filePath = AssetBundleCollectorSettingData.Setting.DLCFiles[i]; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(filePath); if (GUILayout.Button("-", GUILayout.MaxWidth(40))) { AssetBundleCollectorSettingData.RemoveDLC(filePath); break; } } EditorGUILayout.EndHorizontal(); } // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFilePath("Select File", "Assets/"); if (resultPath != null) { string filePath = EditorTools.AbsolutePathToAssetPath(resultPath); AssetBundleCollectorSettingData.AddDLC(filePath); } } }
private void OnGUI() { EditorGUILayout.Space(); // 精灵路径 EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("精灵文件夹路径", GUILayout.MaxWidth(150))) { string resultPath = EditorTools.OpenFolderPanel("Find", UIPanelSettingData.Setting.UISpriteDirectory); if (resultPath != null) { UIPanelSettingData.SetUISpriteDirectory(EditorTools.AbsolutePathToAssetPath(resultPath)); } } EditorGUILayout.LabelField($" : {UIPanelSettingData.Setting.UISpriteDirectory}"); EditorGUILayout.EndHorizontal(); // 图集路径 EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("图集文件夹路径", GUILayout.MaxWidth(150))) { string resultPath = EditorTools.OpenFolderPanel("Find", UIPanelSettingData.Setting.UIAtlasDirectory); if (resultPath != null) { UIPanelSettingData.SetUIAtlasDirectory(EditorTools.AbsolutePathToAssetPath(resultPath)); } } EditorGUILayout.LabelField($" : {UIPanelSettingData.Setting.UIAtlasDirectory}"); EditorGUILayout.EndHorizontal(); }
private void OnDrawCollector() { // 列表显示 EditorGUILayout.Space(); EditorGUILayout.LabelField($"[ Collector ]"); for (int i = 0; i < AssetBundleCollectorSettingData.Setting.Collectors.Count; i++) { var collector = AssetBundleCollectorSettingData.Setting.Collectors[i]; string directory = collector.CollectDirectory; string labelClassName = collector.LabelClassName; string filterClassName = collector.FilterClassName; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(directory); // 标签类 { int index = LabelClassNameToIndex(labelClassName); int newIndex = EditorGUILayout.Popup(index, _labelClassArray, GUILayout.MaxWidth(150)); if (newIndex != index) { labelClassName = IndexToLabelClassName(newIndex); AssetBundleCollectorSettingData.ModifyCollector(directory, labelClassName, filterClassName); } } // 过滤类 { int index = FilterClassNameToIndex(filterClassName); int newIndex = EditorGUILayout.Popup(index, _filterClassArray, GUILayout.MaxWidth(150)); if (newIndex != index) { filterClassName = IndexToFilterClassName(newIndex); AssetBundleCollectorSettingData.ModifyCollector(directory, labelClassName, filterClassName); } } if (GUILayout.Button("-", GUILayout.MaxWidth(40))) { AssetBundleCollectorSettingData.RemoveCollector(directory); break; } } EditorGUILayout.EndHorizontal(); } // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFolderPanel("Select Folder", _lastOpenFolderPath); if (resultPath != null) { _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); AssetBundleCollectorSettingData.AddCollector(_lastOpenFolderPath); } } }
void OnGUI() { // 初始化 if (_isInit == false) { _isInit = true; Init(); } // 列表显示 EditorGUILayout.Space(); for (int i = 0; i < AssetScanerSettingData.Setting.Elements.Count; i++) { string directory = AssetScanerSettingData.Setting.Elements[i].ScanerDirectory; string scanerName = AssetScanerSettingData.Setting.Elements[i].ScanerName; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(directory); int index = NameToIndex(scanerName); int newIndex = EditorGUILayout.Popup(index, _classArray, GUILayout.MaxWidth(150)); if (newIndex != index) { string newScanerName = IndexToName(newIndex); AssetScanerSettingData.ModifyElement(directory, newScanerName); } if (GUILayout.Button("-", GUILayout.MaxWidth(40))) { AssetScanerSettingData.RemoveElement(directory); break; } } EditorGUILayout.EndHorizontal(); } // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFolderPanel("+", _lastOpenFolderPath); if (resultPath != null) { _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); AssetScanerSettingData.AddElement(_lastOpenFolderPath); } } // 扫描按钮 if (GUILayout.Button("Scan")) { _results = AssetScanerSettingData.ScanAllAssets(); } // 绘制扫描结果 DrawResults(); }
private void OnDrawElement() { // 列表显示 EditorGUILayout.Space(); EditorGUILayout.LabelField($"Collector"); for (int i = 0; i < AssetBundleCollectorSettingData.Setting.Collectors.Count; i++) { string directory = AssetBundleCollectorSettingData.Setting.Collectors[i].CollectDirectory; AssetBundleCollectorSetting.ECollectRule packRule = AssetBundleCollectorSettingData.Setting.Collectors[i].CollectRule; string collectorName = AssetBundleCollectorSettingData.Setting.Collectors[i].CollectorName; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(directory); AssetBundleCollectorSetting.ECollectRule newPackRule = (AssetBundleCollectorSetting.ECollectRule)EditorGUILayout.EnumPopup(packRule, GUILayout.MaxWidth(150)); if (newPackRule != packRule) { packRule = newPackRule; AssetBundleCollectorSettingData.ModifyCollector(directory, packRule, collectorName); } int index = NameToIndex(collectorName); int newIndex = EditorGUILayout.Popup(index, _collectorClassArray, GUILayout.MaxWidth(150)); if (newIndex != index) { string newCollectorName = IndexToName(newIndex); AssetBundleCollectorSettingData.ModifyCollector(directory, packRule, newCollectorName); } if (GUILayout.Button("-", GUILayout.MaxWidth(40))) { AssetBundleCollectorSettingData.RemoveCollector(directory); break; } } EditorGUILayout.EndHorizontal(); } // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFolderPanel("Select Folder", _lastOpenFolderPath); if (resultPath != null) { _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); AssetBundleCollectorSettingData.AddCollector(_lastOpenFolderPath); } } }
private void OnGUI() { // 列表显示 EditorGUILayout.Space(); EditorGUILayout.LabelField($"Collection List"); for (int i = 0; i < CollectionSettingData.Setting.Elements.Count; i++) { string folderPath = CollectionSettingData.Setting.Elements[i].FolderPath; CollectionSetting.EFolderPackRule packRule = CollectionSettingData.Setting.Elements[i].PackRule; CollectionSetting.EBundleLabelRule labelRule = CollectionSettingData.Setting.Elements[i].LabelRule; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(folderPath); CollectionSetting.EFolderPackRule newPackRule = (CollectionSetting.EFolderPackRule)EditorGUILayout.EnumPopup(packRule, GUILayout.MaxWidth(150)); if (newPackRule != packRule) { packRule = newPackRule; CollectionSettingData.ModifyElement(folderPath, packRule, labelRule); } CollectionSetting.EBundleLabelRule newLabelRule = (CollectionSetting.EBundleLabelRule)EditorGUILayout.EnumPopup(labelRule, GUILayout.MaxWidth(150)); if (newLabelRule != labelRule) { labelRule = newLabelRule; CollectionSettingData.ModifyElement(folderPath, packRule, labelRule); } if (GUILayout.Button("-", GUILayout.MaxWidth(40))) { CollectionSettingData.RemoveElement(folderPath); break; } } EditorGUILayout.EndHorizontal(); } // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFolderPanel("+", _lastOpenFolderPath); if (resultPath != null) { _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); CollectionSettingData.AddElement(_lastOpenFolderPath); } } }
private void OnGUI() { if (_isInit == false) { _isInit = true; Init(); } // 列表显示 EditorGUILayout.Space(); for (int i = 0; i < ImportSettingData.Setting.Elements.Count; i++) { string folderPath = ImportSettingData.Setting.Elements[i].FolderPath; string processorName = ImportSettingData.Setting.Elements[i].ProcessorName; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(folderPath); int index = NameToIndex(processorName); int newIndex = EditorGUILayout.Popup(index, _processorClassArray, GUILayout.MaxWidth(150)); if (newIndex != index) { string processClassName = IndexToName(newIndex); ImportSettingData.ModifyElement(folderPath, processClassName); } if (GUILayout.Button("-", GUILayout.MaxWidth(40))) { ImportSettingData.RemoveElement(folderPath); break; } } EditorGUILayout.EndHorizontal(); } // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFolderPanel("+", _lastOpenFolderPath); if (resultPath != null) { _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); ImportSettingData.AddElement(_lastOpenFolderPath); } } }
private void OnGUI() { EditorGUILayout.Space(); _saveFilePath = EditorGUILayout.TextField("收集文件保存路径", _saveFilePath); _sceneGameObjects = (GameObject)EditorGUILayout.ObjectField("收集场景内置对象", _sceneGameObjects, typeof(UnityEngine.GameObject), false); int currentShaderCount = ShaderVariantCollector.GetCurrentShaderVariantCollectionShaderCount(); int currentVariantCount = ShaderVariantCollector.GetCurrentShaderVariantCollectionVariantCount(); EditorGUILayout.LabelField($"CurrentShaderCount : {currentShaderCount}"); EditorGUILayout.LabelField($"CurrentVariantCount : {currentVariantCount}"); // 搜集变种 EditorGUILayout.Space(); if (GUILayout.Button("搜集变种", GUILayout.MaxWidth(80))) { ShaderVariantCollector.Run(_saveFilePath, _sceneGameObjects); } // 查询 EditorGUILayout.Space(); if (GUILayout.Button("查询", GUILayout.MaxWidth(80))) { string resultPath = EditorTools.OpenFilePath("Select File", "Assets/", "shadervariants"); if (string.IsNullOrEmpty(resultPath)) { return; } string assetPath = EditorTools.AbsolutePathToAssetPath(resultPath); _selectSVC = AssetDatabase.LoadAssetAtPath <ShaderVariantCollection>(assetPath); } if (_selectSVC != null) { EditorGUILayout.LabelField($"ShaderCount : {_selectSVC.shaderCount}"); EditorGUILayout.LabelField($"VariantCount : {_selectSVC.variantCount}"); } }
private void OnGUI() { // 搜索路径 EditorGUILayout.Space(); if (GUILayout.Button("设置搜索目录", GUILayout.MaxWidth(80))) { string resultPath = EditorTools.OpenFolderPanel("搜索目录", _searchFolderPath); if (resultPath != null) { _searchFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); } } EditorGUILayout.LabelField($"搜索目录:{_searchFolderPath}"); // 搜索类型 _serachType = (EAssetSearchType)EditorGUILayout.EnumPopup("搜索类型", _serachType); // 搜索目标 _searchObject = EditorGUILayout.ObjectField($"搜索目标", _searchObject, typeof(UnityEngine.Object), false); if (_searchObject != null && _searchObject.GetType() == typeof(Texture2D)) { string assetPath = AssetDatabase.GetAssetPath(_searchObject.GetInstanceID()); var spriteObject = AssetDatabase.LoadAssetAtPath <Sprite>(assetPath); if (spriteObject != null) { _searchObject = spriteObject; } } // 执行搜索 EditorGUILayout.Space(); if (GUILayout.Button("搜索")) { if (_searchObject == null) { EditorUtility.DisplayDialog("错误", "请先设置搜索目标", "确定"); return; } string assetPath = AssetDatabase.GetAssetPath(_searchObject.GetInstanceID()); FindReferenceInProject(assetPath, _searchFolderPath, _serachType); } EditorGUILayout.Space(); // 如果字典类为空 if (_collection == null) { return; } // 如果收集列表为空 if (CheckCollectIsEmpty()) { EditorGUILayout.LabelField("提示:没有找到任何被依赖资源。"); return; } _scrollPos = GUILayout.BeginScrollView(_scrollPos); // 显示依赖列表 foreach (EAssetFileExtension value in Enum.GetValues(typeof(EAssetFileExtension))) { List <string> collect = _collection[value]; if (collect.Count == 0) { continue; } string HeaderName = value.ToString(); if (value == EAssetFileExtension.prefab) { HeaderName = "预制体"; } else if (value == EAssetFileExtension.fbx) { HeaderName = "模型"; } else if (value == EAssetFileExtension.cs) { HeaderName = "脚本"; } else if (value == EAssetFileExtension.png || value == EAssetFileExtension.jpg) { HeaderName = "图片"; } else if (value == EAssetFileExtension.mat) { HeaderName = "材质球"; } else if (value == EAssetFileExtension.shader) { HeaderName = "着色器"; } else if (value == EAssetFileExtension.ttf) { HeaderName = "字体"; } else if (value == EAssetFileExtension.anim) { HeaderName = "动画"; } else if (value == EAssetFileExtension.unity) { HeaderName = "场景"; } else { throw new NotImplementedException(value.ToString()); } // 绘制头部 if (EditorTools.DrawHeader(HeaderName)) { // 绘制预制体专属按钮 if (value == EAssetFileExtension.prefab) { if (GUILayout.Button("过滤", GUILayout.MaxWidth(80))) { FilterReference(); } if (GUILayout.Button("FindAll", GUILayout.MaxWidth(80))) { FindAll(collect); } } // 绘制依赖列表 foreach (string item in collect) { EditorGUILayout.BeginHorizontal(); UnityEngine.Object go = AssetDatabase.LoadAssetAtPath(item, typeof(UnityEngine.Object)); if (value == EAssetFileExtension.unity) { EditorGUILayout.ObjectField(go, typeof(SceneView), true); } else { EditorGUILayout.ObjectField(go, typeof(UnityEngine.Object), false); } // 绘制预制体专属按钮 if (value == EAssetFileExtension.prefab) { if (GUILayout.Button("Find", GUILayout.MaxWidth(80))) { FindOne(go as GameObject); } } EditorGUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); }
private void OnDrawCollector() { // 着色器选项 EditorGUILayout.Space(); bool isCollectAllShader = EditorGUILayout.Toggle("收集所有着色器", AssetBundleCollectorSettingData.Setting.IsCollectAllShaders); if (isCollectAllShader != AssetBundleCollectorSettingData.Setting.IsCollectAllShaders) { AssetBundleCollectorSettingData.ModifyShader(isCollectAllShader, AssetBundleCollectorSettingData.Setting.ShadersBundleName); } if (isCollectAllShader) { string shadersBundleName = EditorGUILayout.TextField("AssetBundle名称", AssetBundleCollectorSettingData.Setting.ShadersBundleName); if (shadersBundleName != AssetBundleCollectorSettingData.Setting.ShadersBundleName) { AssetBundleCollectorSettingData.ModifyShader(isCollectAllShader, shadersBundleName); } } // 列表显示 EditorGUILayout.Space(); EditorGUILayout.LabelField($"[ Collector ]"); _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos); for (int i = 0; i < AssetBundleCollectorSettingData.Setting.Collectors.Count; i++) { var collector = AssetBundleCollectorSettingData.Setting.Collectors[i]; string directory = collector.CollectDirectory; string packRuleClassName = collector.PackRuleClassName; string filterRuleClassName = collector.FilterRuleClassName; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(directory); // IPackRule { int index = PackRuleClassNameToIndex(packRuleClassName); int newIndex = EditorGUILayout.Popup(index, _packRuleClassArray, GUILayout.MaxWidth(200)); if (newIndex != index) { packRuleClassName = IndexToPackRuleClassName(newIndex); AssetBundleCollectorSettingData.ModifyCollector(directory, packRuleClassName, filterRuleClassName); } } // IFilterRule { int index = FilterRuleClassNameToIndex(filterRuleClassName); int newIndex = EditorGUILayout.Popup(index, _filterRuleClassArray, GUILayout.MaxWidth(150)); if (newIndex != index) { filterRuleClassName = IndexToFilterRuleClassName(newIndex); AssetBundleCollectorSettingData.ModifyCollector(directory, packRuleClassName, filterRuleClassName); } } if (GUILayout.Button("-", GUILayout.MaxWidth(40))) { AssetBundleCollectorSettingData.RemoveCollector(directory); break; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFolderPanel("Select Folder", _lastOpenFolderPath); if (resultPath != null) { _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); string defaultPackRuleClassName = nameof(PackExplicit); string defaultFilterRuleClassName = nameof(CollectAll); AssetBundleCollectorSettingData.AddCollector(_lastOpenFolderPath, defaultPackRuleClassName, defaultFilterRuleClassName); } } // 导入配置按钮 if (GUILayout.Button("Import Config")) { string resultPath = EditorTools.OpenFilePath("Select Folder", _lastOpenFolderPath); if (resultPath != null) { CollectorConfigImporter.ImportXmlConfig(resultPath); } } }
private void OnDrawCollector() { // 列表显示 EditorGUILayout.Space(); _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos); for (int i = 0; i < AssetBundleCollectorSettingData.Setting.Collectors.Count; i++) { var collector = AssetBundleCollectorSettingData.Setting.Collectors[i]; string directory = collector.CollectDirectory; string packRuleName = collector.PackRuleName; string filterRuleName = collector.FilterRuleName; bool dontWriteAssetPath = collector.DontWriteAssetPath; string assetTags = collector.AssetTags; EditorGUILayout.BeginHorizontal(); { // Directory EditorGUILayout.LabelField(directory, GUILayout.MinWidth(GuiDirecotryMinSize), GUILayout.MaxWidth(GuiDirecotryMaxSize)); // IPackRule { int index = PackRuleNameToIndex(packRuleName); int newIndex = EditorGUILayout.Popup(index, _packRuleArray, GUILayout.MinWidth(GuiPackRuleSize), GUILayout.MaxWidth(GuiPackRuleSize)); if (newIndex != index) { packRuleName = IndexToPackRuleName(newIndex); AssetBundleCollectorSettingData.ModifyCollector(directory, packRuleName, filterRuleName, dontWriteAssetPath, assetTags); } } // IFilterRule { int index = FilterRuleNameToIndex(filterRuleName); int newIndex = EditorGUILayout.Popup(index, _filterRuleArray, GUILayout.MinWidth(GuiFilterRuleSize), GUILayout.MaxWidth(GuiFilterRuleSize)); if (newIndex != index) { filterRuleName = IndexToFilterRuleName(newIndex); AssetBundleCollectorSettingData.ModifyCollector(directory, packRuleName, filterRuleName, dontWriteAssetPath, assetTags); } } // DontWriteAssetPath { bool newToggleValue = EditorGUILayout.Toggle(dontWriteAssetPath, GUILayout.MinWidth(GuiDontWriteAssetPathSize), GUILayout.MaxWidth(GuiDontWriteAssetPathSize)); if (newToggleValue != dontWriteAssetPath) { dontWriteAssetPath = newToggleValue; AssetBundleCollectorSettingData.ModifyCollector(directory, packRuleName, filterRuleName, dontWriteAssetPath, assetTags); } } // AssetTags { string newTextValue = EditorGUILayout.TextField(assetTags, GUILayout.MinWidth(GuiAssetTagsMinSize), GUILayout.MaxWidth(GuiAssetTagsMaxSize)); if (newTextValue != assetTags) { assetTags = newTextValue; AssetBundleCollectorSettingData.ModifyCollector(directory, packRuleName, filterRuleName, dontWriteAssetPath, assetTags); } } if (GUILayout.Button("-", GUILayout.MinWidth(GuiBtnSize), GUILayout.MaxWidth(GuiBtnSize))) { AssetBundleCollectorSettingData.RemoveCollector(directory); break; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); // 添加按钮 if (GUILayout.Button("+")) { string resultPath = EditorTools.OpenFolderPanel("Select Folder", _lastOpenFolderPath); if (resultPath != null) { _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath); string defaultPackRuleName = nameof(PackExplicit); string defaultFilterRuleName = nameof(CollectAll); bool defaultDontWriteAssetPathValue = false; string defaultAssetTag = string.Empty; AssetBundleCollectorSettingData.AddCollector(_lastOpenFolderPath, defaultPackRuleName, defaultFilterRuleName, defaultDontWriteAssetPathValue, defaultAssetTag); } } // 导入配置按钮 if (GUILayout.Button("Import Config")) { string resultPath = EditorTools.OpenFilePath("Select File", "Assets/", "xml"); if (resultPath != null) { CollectorConfigImporter.ImportXmlConfig(resultPath); } } }