public static void SplitAssetBundles2DefaultAndSubProjectDatas(SubProjectData defaultSubProjectData, List <SubProjectData> subProjectDatas)
        {
            var assetBundleNames = AssetDatabase.GetAllAssetBundleNames();

            foreach (var assetBundleName in assetBundleNames)
            {
                var assetBundleBuild = new AssetBundleBuild
                {
                    assetBundleName = assetBundleName,
                    assetNames      = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName)
                };
                var isDefault = true;


                foreach (var subProjectData in subProjectDatas)
                {
                    foreach (var assetName in assetBundleBuild.assetNames)
                    {
                        if (assetName.Contains(subProjectData.Folder))
                        {
                            subProjectData.Builds.Add(assetBundleBuild);
                            isDefault = false;
                            break;
                        }
                    }
                }

                if (isDefault)
                {
                    defaultSubProjectData.Builds.Add(assetBundleBuild);
                }
            }
        }
        public static void BuildAssetBundles(BuildTarget buildTarget)
        {
            // 先清空一下没用的 ab 名字
            AssetDatabase.RemoveUnusedAssetBundleNames();

            var defaultSubProjectData = new SubProjectData();
            var subProjectDatas       = SubProjectData.SearchAllInProject();

            SubProjectData.SplitAssetBundles2DefaultAndSubProjectDatas(defaultSubProjectData, subProjectDatas);

            // Choose the output path according to the build target.
            var outputPath = Path.Combine(ResKitAssetsMenu.AssetBundlesOutputPath, GetPlatformName());

            outputPath.CreateDirIfNotExists();

            BuildPipeline.BuildAssetBundles(outputPath, defaultSubProjectData.Builds.ToArray(),
                                            BuildAssetBundleOptions.ChunkBasedCompression, buildTarget);

            GenerateVersionConfig();

            var finalDir = Application.streamingAssetsPath + "/AssetBundles/" + GetPlatformName();

            finalDir.DeleteDirIfExists();
            finalDir.CreateDirIfNotExists();

            FileUtil.ReplaceDirectory(outputPath, finalDir);

            AssetBundleExporter.BuildDataTable(defaultSubProjectData.Builds.Select(b => b.assetBundleName).ToArray());

            foreach (var subProjectData in subProjectDatas)
            {
                outputPath = Path.Combine(ResKitAssetsMenu.AssetBundlesOutputPath + "/" + subProjectData.Name,
                                          GetPlatformName());
                outputPath.CreateDirIfNotExists();

                BuildPipeline.BuildAssetBundles(outputPath, subProjectData.Builds.ToArray(),
                                                BuildAssetBundleOptions.ChunkBasedCompression, buildTarget);
                finalDir = Application.streamingAssetsPath + "/" + subProjectData.Name + "/AssetBundles/" +
                           GetPlatformName();

                finalDir.DeleteDirIfExists();
                finalDir.CreateDirIfNotExists();

                FileUtil.ReplaceDirectory(outputPath, finalDir);
                AssetBundleExporter.BuildDataTable(subProjectData.Builds.Select(b => b.assetBundleName).ToArray(),
                                                   finalDir + "/");
            }

            AssetDatabase.Refresh();
        }