Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="layer">被依赖的第几层 </param>
        public static bool CollectionResourceInfo(string path, int layer)
        {
            // 依赖关系超过3层 直接报错 整理资源
            if (layer >= 3)
            {
                Debug.LogError("Dependencies Layer Depth over 3 : " + path);
                return(false);
            }

            //如果依赖的内容在打包的路径里面 可以直接忽略
            if (layer > 0 && path.Contains(AB_PATH))
            {
                return(true);
            }

            // 根据规则 获取ab名称
            string abName = GetABNameFromPath(path);

            CollectionPools.CollectionData(path, abName);

            string[] files = AssetDatabase.GetDependencies(path, true);

            for (int i = 0; i < files.Length; i++)
            {
                bool error = CollectionResourceInfo(files[i], layer + 1);

                if (!error)
                {
                    Debug.LogError("Dependencie Error : " + path);
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        public static void BuildAssetBundles(BuildTarget targetPlatform, string outPath)
        {
            Dictionary <string, List <string> > abData = CollectionPools.GetCollectionData();

            List <AssetBundleBuild> abLists = new List <AssetBundleBuild>();

            foreach (var item in abData)
            {
                AssetBundleBuild build = new AssetBundleBuild();
                build.assetBundleName    = item.Key.ToLower();
                build.assetBundleVariant = FileUtility.AssetBundleExt;
                build.assetNames         = item.Value.ToArray();
                abLists.Add(build);
            }

            BuildPipeline.BuildAssetBundles(outPath, abLists.ToArray(), BuildAssetBundleOptions.None, targetPlatform);//LZMA
        }