Пример #1
0
        public static void CollectMainFilter(AssetBundleFilterMain filter, ref AssetBundleCollector collector)
        {
            AssetBundleCollector mainCollector = new AssetBundleCollector();
            AssetBundleCollector subCollector  = new AssetBundleCollector();
            AssetBundleFilter    tmpF;

            mainCollector.Collect(filter.option, filter.resType, filter.path, filter.pattern, filter.assetbundleName);
            if (filter.HasSub())
            {
                for (int i = 0; i < filter.subFilterList.Count; ++i)
                {
                    tmpF = filter.subFilterList[i];
                    if (filter.subFilterList[i].isAppend)
                    {
                        subCollector.CollectAppend(mainCollector, tmpF.option, tmpF.resType, tmpF.path, tmpF.pattern, tmpF.assetbundleName, tmpF.independent);
                    }
                    else
                    {
                        subCollector.Collect(tmpF.option, tmpF.resType, tmpF.path, tmpF.pattern, tmpF.assetbundleName);
                    }
                }
            }
            collector.Mearge(mainCollector);
            collector.Mearge(subCollector);
        }
Пример #2
0
        public static AssetBundleCollector BuildConfig(string path, string pattern, string abName)
        {
            PathUtil.EnsuerStreamingAssetFolder("config");
            AssetBundleCollector collector = AssetBundleCollector.CollectAssetBundlesForFolder(GameResType.None, PathUtil.GetRelativePathToAsset(PathUtil.GetParentDir(path)), pattern, abName);

            collector.Build(Application.streamingAssetsPath.Combine("config"));
            return(collector);
        }
        public static AssetBundleCollector CollectAssetBundlesForFolder(GameResType type, string path, string pattern, string assetbundlename, SearchOption searchOption = SearchOption.AllDirectories)
        {
            AssetCollector          collector            = AssetCollector.CreateAndCollect(path, pattern, type, searchOption);
            List <AssetBundleBuild> buildList            = new List <AssetBundleBuild>();
            AssetBundleCollector    assetbundleCollector = new AssetBundleCollector();

            assetbundleCollector.AddBuilder(assetbundlename, collector);
            return(assetbundleCollector);
        }
Пример #4
0
        public static void GenVersion(AssetBundleCollector collector)
        {
            AssetDatabase.Refresh();
            VersionConfig vc = VersionGenerator.GenerateVersionConfig(collector);

            VersionGenerator.WriteVersionConfig(vc);
            AssetDatabase.Refresh();
            BuildConfig(PathConfig.version, "version.txt", "version");
        }
        public void Mearge(AssetBundleCollector bundleCollector)
        {
            if (bundleCollector == null || bundleCollector.IsEmpty())
            {
                return;
            }
            List <AssetBundleBuild> list = bundleCollector.GetBuildList();

            this.buildList.AddRange(list);
        }
        public static AssetBundleCollector CollectAssetbundlesForEachFile(GameResType type, string path, string pattern, string format = "{0}", SearchOption searchOption = SearchOption.AllDirectories)
        {
            AssetCollector       collector            = AssetCollector.CreateAndCollect(path, pattern, type, searchOption);
            AssetBundleCollector assetbundleCollector = new AssetBundleCollector();

            if (collector == null)
            {
                return(assetbundleCollector);
            }
            assetbundleCollector.AddBuilderList(format, collector);
            return(assetbundleCollector);
        }
Пример #7
0
        public static void Build(AssetBundleBuildConfig config, bool isGenRes = false)
        {
            OnBuildStart(config, isGenRes);
            AssetBundleCollector collector = Collect(config);

            OnCollectFinish();
            if (!isGenRes)
            {
                collector.Build(Application.streamingAssetsPath);
            }
            OnBuildEnd(collector, isGenRes);
        }
Пример #8
0
        public static void OnBuildEnd(AssetBundleCollector collector, bool isGen)
        {
            BuildBoy.ClearLua();

            if (!isGen)
            {
                BuildBoy.ChangeUIToSprite();
                GenVersion(collector);
            }
            AssetDatabase.Refresh();
            Resources.UnloadUnusedAssets();
            Debug.Log("打包结束!");
        }
Пример #9
0
        public static AssetBundleCollector Collect(AssetBundleBuildConfig config)
        {
            AssetBundleCollector collector = new AssetBundleCollector();

            for (int i = 0; i < config.filters.Count; ++i)
            {
                AssetBundleFilterMain filter = config.filters[i];
                if (filter.valid)
                {
                    CollectMainFilter(filter, ref collector);
                }
            }
            return(collector);
        }
        public static AssetBundleCollector CollectAssetbundlesForEachSubFolder(GameResType type, string path, string pattern, string format = "{0}", SearchOption searchOption = SearchOption.AllDirectories)
        {
            string fullpath = PathUtil.GetFullPath(path);
            AssetBundleCollector assetBundleCollector = new AssetBundleCollector();

            if (!Directory.Exists(fullpath))
            {
                return(assetBundleCollector);
            }

            string[] dirList = Directory.GetDirectories(fullpath);
            List <AssetBundleBuild> bulldList = new List <AssetBundleBuild>();

            foreach (string dir in dirList)
            {
                string               fullPath  = dir.Replace("\\", "/");
                string[]             splitName = PathUtil.splitePath(fullPath);
                string               name      = string.Format(format, splitName);
                AssetBundleCollector abc       = CollectAssetBundlesForFolder(type, PathUtil.GetRelativePathToDataPath(fullPath), pattern, name, searchOption);
                assetBundleCollector.Mearge(abc);
            }
            return(assetBundleCollector);
        }
 public void CollectAppend(AssetBundleCollector mainCollector, BuildOption option, GameResType resType, string path, string pattern, string assetbundleName, bool independent, SearchOption searchOption = SearchOption.AllDirectories)
 {
     for (int i = 0; i < mainCollector.buildList.Count; ++i)
     {
         AssetBundleBuild bd         = mainCollector.buildList[i];
         string           name       = PathUtil.GetFileNameWithoutExtension(bd.assetBundleName);
         string           formatPath = string.Format(path, name);
         if (independent)
         {
             Collect(option, resType, formatPath, pattern, assetbundleName);
         }
         else
         {
             AssetCollector collector  = AssetCollector.CreateAndCollect(formatPath, pattern, resType, searchOption);
             List <string>  assetList  = new List <string>(bd.assetNames);
             List <string>  assetList2 = new List <string>(collector.ToAssetStringList());
             assetList.AddRange(assetList2);
             bd.assetNames = assetList.ToArray();
             mainCollector.buildList[i] = bd;
             collector.UpdateGameTable(bd.assetBundleName);
         }
     }
 }
Пример #12
0
        public static VersionConfig GenerateVersionConfig(AssetBundleCollector collector)
        {
            VersionConfig vc = VersionUtil.ReadConfig("config/version") ?? new VersionConfig();

            VersionConfig newVC = new VersionConfig();

            newVC.version = vc.version + 1;

            List <AssetBundleBuild> buildList = collector.GetBuildList();

            for (int i = 0; i < buildList.Count; ++i)
            {
                AssetBundleBuild build = buildList[i];
                string           file  = Application.streamingAssetsPath.Combine(build.assetBundleName);
                if (PathUtil.ExistsFile(file))
                {
                    FileStream fs    = new FileStream(file, FileMode.Open);
                    byte[]     bytes = new byte[fs.Length];
                    fs.Read(bytes, 0, bytes.Length);
                    string md5 = CryptUtil.GetMD5(bytes);
                    fs.Close();
                    VersionFileConfig vfc = new VersionFileConfig();
                    vfc.path     = build.assetBundleName;
                    vfc.md5      = md5;
                    vfc.sizeByte = bytes.Length;
                    if (!newVC.fileDict.ContainsKey(vfc.path))
                    {
                        newVC.fileDict.Add(vfc.path, vfc);
                    }
                    else
                    {
                        Debug.LogError("重复资源:" + vfc.path);
                    }
                }
            }
            return(newVC);
        }
        public void CollectEachFile(GameResType type, string path, string pattern, string assetbundleName, SearchOption searchOption = SearchOption.AllDirectories)
        {
            AssetBundleCollector abcollector = CollectAssetbundlesForEachFile(type, path, pattern, assetbundleName, searchOption);

            this.Mearge(abcollector);
        }
        public void CollectEachSubFolder(GameResType type, string path, string pattern, string format = "{0}", SearchOption searchOption = SearchOption.AllDirectories)
        {
            AssetBundleCollector abcollector = CollectAssetbundlesForEachSubFolder(type, path, pattern, format, searchOption);

            this.Mearge(abcollector);
        }