public override void SetDataPaths(string refPathStr, string pathStr, string commonPathStr)
        {
            base.SetDataPaths(refPathStr, pathStr, commonPathStr);
            var style = AssetDanshariStyle.Get();

            var resFileList = GetResFileList();
            var fileList    = GetFileMd5Infos(resFileList);

            if (fileList == null || fileList.Count == 0)
            {
                return;
            }

            var rootInfo = new AssetInfo(GetAutoId(), String.Empty, String.Empty);
            var groups   = fileList.GroupBy(info => info.md5).Where(g => g.Count() > 1);

            foreach (var group in groups)
            {
                AssetInfo dirInfo = new AssetInfo(GetAutoId(), String.Empty, String.Format(style.duplicateGroup, group.Count()));
                dirInfo.isExtra = true;
                rootInfo.AddChild(dirInfo);

                foreach (var member in group)
                {
                    dirInfo.AddChild(GetAssetInfoByFileMd5Info(member));
                }
            }

            if (rootInfo.hasChildren)
            {
                data = rootInfo;
            }
            EditorUtility.ClearProgressBar();
        }
예제 #2
0
        private void DirToAssetInfoTreeSub(AssetInfo rootInfo, string path)
        {
            var allDirs = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly);

            foreach (var drDir in allDirs)
            {
                AssetInfo info = GenAssetInfo(drDir);
                rootInfo.AddChild(info);

                DirToAssetInfoTreeSub(info, drDir);
            }
        }
예제 #3
0
    /// <summary>
    /// 从这里开始分析构建资源依赖树
    /// </summary>
    /// <param name="parent"></param>
    public void AddParent(AssetInfo parent)
    {
        if (parent == this || IsParentEarlyDep(parent) || parent == null)
        {
            return;
        }

        parentSet.Add(parent);
        parent.AddChild(this);

        parent.RemoveRepeatChildDep(this);
        RemoveRepeatParentDep(parent);
    }
예제 #4
0
        /// <summary>
        /// 首先构建目录树
        /// </summary>
        protected AssetInfo DirToAssetInfoTree(string[] paths)
        {
            var rooInfo = new AssetInfo(GetAutoId(), String.Empty, String.Empty);

            rooInfo.isFolder = true;

            foreach (var path in paths)
            {
                if (!Directory.Exists(path))
                {
                    continue;
                }

                AssetInfo info = GenAssetInfo(path);
                rooInfo.AddChild(info);
                DirToAssetInfoTreeSub(info, path);
            }

            return(rooInfo);
        }
        /// <summary>
        /// 手动添加数据
        /// </summary>
        /// <param name="filePaths"></param>
        public int AddManualData(string[] filePaths)
        {
            var fileList = GetFileMd5Infos(filePaths.ToList());

            if (fileList == null || fileList.Count < 2 || !HasData())
            {
                EditorUtility.ClearProgressBar();
                return(0);
            }

            var       style   = AssetDanshariStyle.Get();
            AssetInfo dirInfo = new AssetInfo(GetAutoId(), String.Empty, String.Format(style.duplicateGroup, fileList.Count));

            dirInfo.isExtra = true;
            data.AddChild(dirInfo);

            foreach (var member in fileList)
            {
                dirInfo.AddChild(GetAssetInfoByFileMd5Info(member));
            }
            EditorUtility.ClearProgressBar();
            return(dirInfo.children[dirInfo.children.Count - 1].id);
        }
예제 #6
0
        public override void SetDataPaths(List <string> queryPahts)
        {
            base.SetDataPaths(queryPahts);
            data = FileListToAssetInfos(queryPahts);

            List <string> fileList = AssetDanshariUtility.GetAllFile(AssetDanshariUtility.ValidFile);
            var           rstList  = AssetDanshariUtility.ResultList(fileList.Count, queryPahts.Count);

            ThreadDoFilesTextSearch(fileList, queryPahts, rstList);

            for (int i = 0; i < fileList.Count; i++)
            {
                for (int j = 0; j < queryPahts.Count; j++)
                {
                    if (rstList[i][j])
                    {
                        AssetInfo info = GenAssetInfo(fileList[i]);
                        info.isRst = true;
                        data[j].AddChild(info);
                    }
                }
            }

            string[] md5Array = new string[queryPahts.Count];
            ThreadDoFileMD5(queryPahts, md5Array);
            Dictionary <string, List <AssetInfo> > dic = new Dictionary <string, List <AssetInfo> >();

            for (int i = 0; i < md5Array.Length; i++)
            {
                string           md5  = md5Array[i];
                List <AssetInfo> list = null;
                if (dic.TryGetValue(md5, out list))
                {
                    list.Add(data[i]);
                }
                else
                {
                    dic.Add(md5, new List <AssetInfo>()
                    {
                        data[i]
                    });
                }
            }
            var assetInfos = new List <AssetInfo>();

            foreach (var pair in dic)
            {
                if (pair.Value.Count < 2)
                {
                    continue;
                }
                AssetInfo dirInfo = new AssetInfo(GetAutoId(), String.Empty, String.Format(AssetDanshariStyle.Get().duplicateGroup, pair.Value.Count()));
                for (int i = 0; i < pair.Value.Count; i++)
                {
                    dirInfo.AddChild(pair.Value[i]);
                }
                assetInfos.Add(dirInfo);
            }

            if (assetInfos.Count > 0)
            {
                data = assetInfos;
            }
            else
            {
                data = null;
            }
            EditorUtility.ClearProgressBar();
        }