Ejemplo n.º 1
0
        //每个文件单独达成bundle( 完整路径 )
        private static AssetBundleBuild[] AddFilesToBundleBuilds(string[] files, AssetBundleFlag flag)
        {
            //  d:/../../../Assets/Dow/Res/Default/Prefabs/EffRes/xx.prefab
            //  ---> prefabs/effres/xx.prefab
            ProcessPath(files);
            List <AssetBundleBuild> builds = new List <AssetBundleBuild>();

            for (int i = 0; i < files.Length; ++i)
            {
                AssetBundleBuild abb = new AssetBundleBuild();

                string filePath = RemoveSuffix(files[i]);
                filePath            = NormalizePathFormat(filePath);
                abb.assetBundleName = filePath.Replace(flag.relativePath.Trim('/'), flag.rootBundleName) + ResourceConfig.AssetBundleNameSuffix;
                abb.assetNames      = new string[1] {
                    files[i]
                };
                builds.Add(abb);
            }
            return(builds.ToArray());
        }
Ejemplo n.º 2
0
        private static void AddFlagToBuildMap(AssetBundleFlag flag, List <AssetBundleBuild> buildMap)
        {
            if (buildMap == null)
            {
                return;
            }

            //获取所有文件夹
            string[] files        = null;
            string   absolutePath = TranslateToAbsolutePath(flag.relativePath);

            switch (flag.bundleType)
            {
            case BundleType.Folder:
                //将整个文件夹做成bundle
                buildMap.Add(AddFolderToBundleBuild(absolutePath, flag, flag.rootBundleName));
                break;

            case BundleType.Single:
                //将单个的文件做成bundle
                files = GetFiles(absolutePath, flag.suffix, SearchOption.AllDirectories);
                buildMap.AddRange(AddFilesToBundleBuilds(files, flag));
                break;

            case BundleType.SingleFolder:
                AddTopFolderToBuildMap(absolutePath, flag, buildMap);
                break;

            case BundleType.SingleFolderAndTopFiles:
                //子文件夹
                AddTopFolderToBuildMap(absolutePath, flag, buildMap);
                //获取所有单独文件
                files = GetFiles(absolutePath, flag.suffix, SearchOption.TopDirectoryOnly);
                buildMap.AddRange(AddFilesToBundleBuilds(files, flag));
                break;
            }
        }