Example #1
0
        private void OnDrawShader()
        {
            bool   isCollectAllShader = AssetBundleCollectorSettingData.Setting.IsCollectAllShaders;
            string shadersBundleName  = AssetBundleCollectorSettingData.Setting.ShadersBundleName;

            EditorGUILayout.Space();

            bool newToggleValue = EditorGUILayout.Toggle("收集所有着色器", isCollectAllShader);

            if (newToggleValue != isCollectAllShader)
            {
                isCollectAllShader = newToggleValue;
                AssetBundleCollectorSettingData.ModifyShader(isCollectAllShader, shadersBundleName);
            }

            if (isCollectAllShader)
            {
                string newTextValue = EditorGUILayout.TextField("AssetBundle名称", shadersBundleName, GUILayout.MaxWidth(300));
                if (newTextValue != shadersBundleName)
                {
                    shadersBundleName = newTextValue;
                    AssetBundleCollectorSettingData.ModifyShader(isCollectAllShader, shadersBundleName);
                }
            }
        }
Example #2
0
        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);
                }
            }
        }