Exemplo n.º 1
0
        /// <summary>
        /// Bundle的信息
        /// </summary>
        /// <param name="node"></param>
        /// <param name="allTree"></param>
        public AssetBundleInfo(AssetDependenctGraph.Node node, Dictionary <string, AssetDependenctGraph.Node> allTree, SortedList <string, AssetBundleInfo> __sortedBundleTree)
        {
            this.selfNode = node;

            Tree = allTree;

            sortedBundleTree = __sortedBundleTree;

            var info = new FileInfo(node.NodePath);

            //检测是否必须单独进行打包
            if (AssetPathRule.IsMustBuild(node.NodePath))
            {
                alone_set = true;
            }

            size = info.Length;

            lastWriteTime = info.LastWriteTime;

            //查询构建被引用了多少次
            BuildBeDependenctCount(this.selfNode);

            //this.guid = AssetDatabase.AssetPathToGUID(BuildUtils.GetAssetRelativePath(this.selfNode.NodePath));

            //guid = AssetDatabase.AssetPathToGUID(this.selftree.assetPath);
            //var extension = Path.GetExtension(this.selfNode.NodePath);

            //获取资源打包的类型数据
            type = AssetFileType.GetAssetBundleBuildType(this.selfNode.NodePath, Path.GetExtension(this.selfNode.NodePath));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 是否为目录打包
        /// </summary>
        /// <param name="url"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        static AssetBundleBuildType IsDirectoryPackage(string url, AssetBundleBuildType type)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(type);
            }

            if (type == AssetBundleBuildType.FBX)
            {
                if (AssetPathRule.IsDirectoryBuild(url))
                {
                    return(AssetBundleBuildType.Animation_FBX);
                }

                return(type);
            }
            else
            {
                return(type);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 按照目录进行打包
        /// </summary>
        static AssetBundleBuild[] BuildDirectoryPackage(Dictionary <string, AssetDependenctGraph.Node> all)
        {
            List <AssetBundleBuild> singleBuilds = new List <AssetBundleBuild>();

            //需要进行目录打包的资源
            Dictionary <string, List <AssetBundleInfo> > dic = new Dictionary <string, List <AssetBundleInfo> >();

            for (int oneIndex = 0; oneIndex < AssetBundleInfo.DirectoryTypes.Length; oneIndex++)
            {
                foreach (var result in all)
                {
                    var node = result.Value;

                    AssetBundleInfo bundle;

                    //获取一个没有后缀名的全路径
                    var bundleKey = BuildUtils.GetPathDirWithoutExtension(node.NodePath);

                    if (!bundleListEx.TryGetValue(bundleKey, out bundle))
                    {
                        bundle = new AssetBundleInfo(node, all, bundleListEx);

                        bundleListEx.Add(bundleKey, bundle);
                    }

                    //检测是否为当前同种类型
                    if (AssetBundleInfo.DirectoryTypes[oneIndex] == bundle.type)
                    {
                        bundle.MarkAsBuild();

                        string url = Path.GetDirectoryName(node.NodePath);

                        if (dic.ContainsKey(url))
                        {
                            dic[url].Add(bundle);
                        }
                        else
                        {
                            List <AssetBundleInfo> list = new List <AssetBundleInfo>();
                            list.Add(bundle);
                            dic[url] = list;
                        }
                    }
                }


                foreach (var item in dic)
                {
                    var singleBuild = new AssetBundleBuild();

                    var assetPath = AssetPathRule.GetDirectoryBuildBundlePath(item.Key) + extension;

                    singleBuild.assetBundleName = assetPath;

                    var list = item.Value;

                    singleBuild.assetNames = new string[list.Count];

                    for (int i = 0; i < list.Count; i++)
                    {
                        singleBuild.assetNames[i] = list[i].selfNode.NodePath;
                    }

                    singleBuilds.Add(singleBuild);
                }
            }

            return(singleBuilds.ToArray());
        }