Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        public static void ModifyCollector(string directory, AssetBundleCollectorSetting.ECollectRule collectRule, string collectorName)
        {
            // 注意:这里强制修改忽略文件夹的命名规则为None
            if (collectRule == AssetBundleCollectorSetting.ECollectRule.Ignore)
            {
                collectorName = nameof(LabelNone);
            }

            for (int i = 0; i < Setting.Collectors.Count; i++)
            {
                if (Setting.Collectors[i].CollectDirectory == directory)
                {
                    Setting.Collectors[i].CollectRule   = collectRule;
                    Setting.Collectors[i].CollectorName = collectorName;
                    break;
                }
            }
            SaveFile();
        }