示例#1
0
        protected virtual AssetProcessCheckfile OnUpdate(string srcFilePath, AssetProcessCheckfile checkfile)
        {
            string nowMd5 = GetFileMd5(srcFilePath);

            checkfile.md5 = nowMd5;

            return(checkfile);
        }
示例#2
0
        //为false时重新生成
        protected virtual bool OnCheck(string srcFilePath, AssetProcessCheckfile checkfile) //对指纹文件进行检查
        {
            bool   ret         = true;
            string recordedMd5 = checkfile.md5;
            string nowMd5      = GetFileMd5(srcFilePath);

            //判断Md5,不区分大小写
            if (string.Compare(recordedMd5, nowMd5, true) == 0)
            {
                ret = false;
            }

            return(ret);
        }
示例#3
0
        protected bool SaveCheckfile(string srcPath, AssetProcessCheckfile checkfile)
        {
            if (checkfile == null)
            {
                return(false);
            }

            string checkfileSavePath = GetCheckfilePath(srcPath);

            if (!XFileTools.Exists(checkfileSavePath))
            {
                string checkfileParentPath = Path.GetDirectoryName(checkfileSavePath);
                if (!XFolderTools.Exists(checkfileParentPath))
                {
                    XFolderTools.CreateDirectory(checkfileParentPath);
                }
            }

            AssetDatabase.DeleteAsset(checkfileSavePath);
            AssetDatabase.CreateAsset(checkfile, checkfileSavePath);

            return(true);
        }
示例#4
0
 public AssetProcessCheckfile(AssetProcessCheckfile other)
 {
     this.md5 = other.md5;
 }
示例#5
0
        private void DoAssets()
        {
            string[] assetFiles = OnFiles();
            if (assetFiles == null || assetFiles.Length < 0)
            {
                return;
            }

            List <FileInfo> procressList = new List <FileInfo>();

            foreach (var file in assetFiles)
            {
                if (string.IsNullOrEmpty(file))
                {
                    continue;
                }

                string realPath = XPathTools.GetRelativePath(file); //路径做Key,有的资源可能名字相同
                realPath = XPathTools.NormalizePath(realPath);

                if (_assetMap.ContainsKey(realPath))
                {
                    continue;
                }

                string checkKey1 = Path.GetFileNameWithoutExtension(realPath);
                string checkKey2 = XStringTools.SplitPathKey(realPath);
                if (!_processPath2srcAssetPath.ContainsKey(checkKey1))
                {
                    _processPath2srcAssetPath.Add(checkKey1, realPath);
                }
                if (!_processPath2srcAssetPath.ContainsKey(checkKey2))
                {
                    _processPath2srcAssetPath.Add(checkKey2, realPath);
                }


                string checkFilePath = GetCheckfilePath(realPath);

                if (!_checkfilePath2srcAssetPath.ContainsKey(checkFilePath))
                {
                    _checkfilePath2srcAssetPath.Add(checkFilePath, realPath);
                }

                AssetProcessCheckfile checkfile = LoadCheckfile(realPath);
                if (!OnCheck(realPath, checkfile))   //如果生成的文件没了,也应该重新生成
                {
                    continue;
                }

                FileInfo fileInfo = new FileInfo();
                fileInfo.path      = realPath;
                fileInfo.checkfile = checkfile;

                _assetMap.Add(realPath, fileInfo);
                procressList.Add(fileInfo);
            }

            foreach (var doFileInfo in procressList)
            {
                var realPath     = doFileInfo.path;
                var processFiles = OnOnce(realPath);
                if (processFiles != null && processFiles.Length > 0)
                {
                    foreach (var processPath in processFiles)
                    {
                        if (!_processPath2srcAssetPath.ContainsKey(processPath))
                        {
                            _processPath2srcAssetPath.Add(processPath, realPath);
                        }
                    }
                }

                //保存Checkfile
                if (_assetMap.TryGetValue(realPath, out var fileInfo))
                {
                    var newCheckfile = OnUpdate(fileInfo.path, fileInfo.checkfile);
                    SaveCheckfile(fileInfo.path, newCheckfile);
                }
            }
        }