Exemple #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));
        }
Exemple #2
0
        /// <summary>
        /// 获取所有的目录合适的文件
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        public static string[] GetAllFile(string root = "Assets/Resources/Res")
        {
            var searchPattern = AssetFileType.GetSearchPattern();

            //return searchPattern.SelectMany(i => Directory.GetFiles(root, i, SearchOption.AllDirectories)).Distinct().ToArray();

            return(searchPattern.SelectMany(i => SelectFile(root, i)).Distinct().ToArray());
        }
            /// <summary>
            /// 检测当前文件是否为shader文件
            /// </summary>
            /// <returns></returns>
            public bool IsShader()
            {
                if (string.IsNullOrEmpty(NodePath))
                {
                    return(false);
                }

                string extension = BuildUtils.GetPathExtension(NodePath);

                if (AssetFileType.GetAssetBundleBuildType(NodePath, extension) == AssetBundleBuildType.Shader)
                {
                    return(true);
                }
                return(false);
            }
Exemple #4
0
        /// <summary>
        /// 获取依赖关系
        /// </summary>
        /// <param name="assetPath"></param>
        /// <returns></returns>
        public static string[] GetDependencies(string assetPath)
        {
            //如果一个资源是需要剔除的资源,那么就不获取它的引用数据(.unity文件的烘焙数据会引用 .unity 文件 造成相互引用)
            if (AssetFileType.IsExcludeResDependenct(assetPath))
            {
                return new string[1] {
                           assetPath
                }
            }
            ;

            var assetDependencies = AssetDatabase.GetDependencies(new string[] { assetPath });

            return(assetDependencies);
        }
Exemple #5
0
        /// <summary>
        /// 查找需要进行的文件数据
        /// </summary>
        /// <param name="root"></param>
        /// <param name="pattern"></param>
        /// <returns></returns>
        static string[] SelectFile(string root, string pattern)
        {
            string[]      str  = Directory.GetFiles(root, pattern, SearchOption.AllDirectories);
            List <string> list = new List <string>(str);

            for (int i = 0; i < list.Count;)
            {
                if (AssetFileType.IsExclude(list[i]))
                {
                    list.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }

            return(list.ToArray());
        }