コード例 #1
0
        private void OnGUI()
        {
            // 列表显示
            EditorGUILayout.Space();
            EditorGUILayout.LabelField($"Collection List");
            for (int i = 0; i < AssetBundleCollectorSettingData.Setting.Elements.Count; i++)
            {
                string folderPath = AssetBundleCollectorSettingData.Setting.Elements[i].FolderPath;
                AssetBundleCollectorSetting.EFolderPackRule  packRule  = AssetBundleCollectorSettingData.Setting.Elements[i].PackRule;
                AssetBundleCollectorSetting.EBundleLabelRule labelRule = AssetBundleCollectorSettingData.Setting.Elements[i].LabelRule;

                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField(folderPath);

                    AssetBundleCollectorSetting.EFolderPackRule newPackRule = (AssetBundleCollectorSetting.EFolderPackRule)EditorGUILayout.EnumPopup(packRule, GUILayout.MaxWidth(150));
                    if (newPackRule != packRule)
                    {
                        packRule = newPackRule;
                        AssetBundleCollectorSettingData.ModifyElement(folderPath, packRule, labelRule);
                    }

                    AssetBundleCollectorSetting.EBundleLabelRule newLabelRule = (AssetBundleCollectorSetting.EBundleLabelRule)EditorGUILayout.EnumPopup(labelRule, GUILayout.MaxWidth(150));
                    if (newLabelRule != labelRule)
                    {
                        labelRule = newLabelRule;
                        AssetBundleCollectorSettingData.ModifyElement(folderPath, packRule, labelRule);
                    }

                    if (GUILayout.Button("-", GUILayout.MaxWidth(40)))
                    {
                        AssetBundleCollectorSettingData.RemoveElement(folderPath);
                        break;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            // 添加按钮
            if (GUILayout.Button("+"))
            {
                string resultPath = EditorTools.OpenFolderPanel("+", _lastOpenFolderPath);
                if (resultPath != null)
                {
                    _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath);
                    AssetBundleCollectorSettingData.AddElement(_lastOpenFolderPath);
                }
            }
        }