Ejemplo n.º 1
0
        private void BuildLuaFile(string dir)
        {
            string path = BuildDefaultPath.GetLuaTempDataPath + dir;

            string[] files = Directory.GetFiles(path, "*.lua.bytes");

            string _bundleName = "lua";

            for (int i = 0; i < files.Length; i++)
            {
                files[i] = files[i].Replace('\\', '/');
            }

            if (dir != null)
            {
                dir         = dir.Replace('\\', '_').Replace('/', '_');
                _bundleName = "lua_" + dir.ToLower();
            }

            _bundleName = BuildDefaultPath.GetLuaTempDataPath + "/" + _bundleName;

            AssetBundleBuild build = new AssetBundleBuild();

            bundleName            = BuildDefaultPath.BuildAssetBunldNameWithAssetPath(path);
            build.assetBundleName = _bundleName;
            build.assetNames      = files;
            builds.Add(build);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 将搜索到的所有资源按资源所在的路径进行打包,同一个路径下的所有资源会被打到一个包。(将searchPath路径下的按各自目录结构打成各自的包)
        /// 粒度适中
        /// </summary>
        public override void Build()
        {
            var files = GetFilesWithoutPacked(searchPath, searchPattern, option);
            Dictionary <string, List <string> > bundles = new Dictionary <string, List <string> >();

            for (int i = 0; i < files.Count; i++)
            {
                var item = files[i];
                if (UnityEditor.EditorUtility.DisplayCancelableProgressBar(string.Format("Collecting... [{0}/{1}]", i, files.Count), item, i * 1f / files.Count))
                {
                    break;
                }

                var path = Path.GetDirectoryName(item);
                if (!bundles.ContainsKey(path))   //按目录添加
                {
                    bundles[path] = new List <string>();
                }

                bundles[path].Add(item);
                bundles[path].AddRange(GetDependencies(item));
            }
            int count = 0;

            foreach (var item in bundles)
            {
                AssetBundleBuild build = new AssetBundleBuild();
                build.assetBundleName = BuildDefaultPath.BuildAssetBunldNameWithAssetPath(item.Key);
                build.assetNames      = item.Value.ToArray();
                packedAssets.AddRange(build.assetNames);
                builds.Add(build);
                if (UnityEditor.EditorUtility.DisplayCancelableProgressBar(string.Format("Packing... [{0}/{1}]", count, bundles.Count), build.assetBundleName, count * 1f / bundles.Count))
                {
                    break;
                }

                count++;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 将搜索到的所有资源按每个资源的文件名进行打包,每个文件一个包。(将searchPath路径下的。每一个文件进行依次打包)
        /// 粒度最小
        /// </summary>
        public override void Build()
        {
            var files = GetFilesWithoutPacked(searchPath, searchPattern, option);

            for (int i = 0; i < files.Count; i++)
            {
                var item = files[i];
                if (EditorUtility.DisplayCancelableProgressBar(string.Format("Packing... [{0}/{1}]", i, files.Count),
                                                               item, i * 1f / files.Count))
                {
                    break;
                }

                AssetBundleBuild build = new AssetBundleBuild();
                build.assetBundleName = BuildDefaultPath.BuildAssetBunldNameWithAssetPath(item);
                var assetNames = GetDependencies(item);
                assetNames.Add(item);
                build.assetNames = assetNames.ToArray();
                packedAssets.AddRange(assetNames);
                builds.Add(build);
            }
        }
Ejemplo n.º 4
0
 public override string GetAssetBundleName(string assetPath)
 {
     return(BuildDefaultPath.BuildAssetBunldNameWithAssetPath(Path.GetDirectoryName(assetPath)));
 }