Exemple #1
0
        /////////////
        private string GetCheckfilePath(string srcPath)
        {
            string checkfileSavePath = AssetProcesserConfiger.GetInstance().GetCheckfileSavePath(_progresersName, srcPath, ".asset");
            var    outName           = OnCheckFileName(srcPath);

            if (!string.IsNullOrEmpty(outName))
            {
                string exName     = Path.GetExtension(checkfileSavePath);
                string parentPath = Path.GetDirectoryName(checkfileSavePath);
                checkfileSavePath = XPathTools.Combine(parentPath, string.Format("{0}{1}", outName, exName));
            }
            return(checkfileSavePath);
        }
Exemple #2
0
        protected override void OnShow()
        {
            GUILayout.BeginVertical();
            if (GUILayout.Button("处理"))
            {
                AssetProcesserManager.GetInstance().Do();
            }

            AssetProcesserConfiger.GetInstance().outputFolderPath          = GUILayoutEx.ShowPathBar("后处理输出目录", AssetProcesserConfiger.GetInstance().outputFolderPath);
            AssetProcesserConfiger.GetInstance().processFolderName         = EditorGUILayout.TextField("处理文件目录名", AssetProcesserConfiger.GetInstance().processFolderName);
            AssetProcesserConfiger.GetInstance().checkfileFolderName       = EditorGUILayout.TextField("检查文件目录名", AssetProcesserConfiger.GetInstance().checkfileFolderName);
            AssetProcesserConfiger.GetInstance().createFolderOrAddSuffix   = EditorGUILayout.Toggle("为检查文件创建存放目录", AssetProcesserConfiger.GetInstance().createFolderOrAddSuffix);
            AssetProcesserConfiger.GetInstance().useGUID4SaveCheckfileName = EditorGUILayout.Toggle("用GUID作为检查文件名", AssetProcesserConfiger.GetInstance().useGUID4SaveCheckfileName);

            GUILayout.EndVertical();
        }
Exemple #3
0
        private void DoStart()
        {
            _assetMap.Clear();
            _checkfilePath2srcAssetPath.Clear();
            _processPath2srcAssetPath.Clear();

            string processFolderPath = AssetProcesserConfiger.GetInstance().GetProcessFloderPath();

            if (!XFolderTools.Exists(processFolderPath))
            {
                XFolderTools.CreateDirectory(processFolderPath);
            }

            string outputPath = AssetProcesserConfiger.GetInstance().GetProcessSaveFolderPath(_progresersName);

            if (!XFolderTools.Exists(outputPath))
            {
                XFolderTools.CreateDirectory(outputPath);
            }

            OnStart();
        }
Exemple #4
0
        private void DoEnd()
        {
            //处理无效的Checkfile文件
            string checkfileFolderPath     = AssetProcesserConfiger.GetInstance().GetCheckfileSaveFolderPath(_progresersName); //TODO:这里如果全部放到一个路径下,会被别的干扰到了
            bool   isUseGUID               = AssetProcesserConfiger.GetInstance().useGUID4SaveCheckfileName;
            bool   createFolderOrAddSuffix = AssetProcesserConfiger.GetInstance().createFolderOrAddSuffix;

            XFolderTools.TraverseFiles(checkfileFolderPath, (fullPath) =>
            {
                string exName = Path.GetExtension(fullPath).ToLower();
                if (exName.Contains("meta"))
                {
                    return;
                }

                string realPath    = XPathTools.GetRelativePath(fullPath); //路径做Key,有的资源可能名字相同
                string realPathLow = realPath.ToLower();
                if (isUseGUID)
                {
                    string srcPath = AssetDatabase.GUIDToAssetPath(realPath);

                    if (string.IsNullOrEmpty(srcPath) || !_assetMap.ContainsKey(realPathLow))
                    {
                        XFileTools.Delete(fullPath);
                    }
                }
                else
                {
                    bool canDelete = true;
                    if (!createFolderOrAddSuffix)
                    {
                        string fileNameWithoutEx = Path.GetFileNameWithoutExtension(realPath);
                        if (!fileNameWithoutEx.EndsWith(_progresersName))
                        {
                            canDelete = false;
                        }
                    }

                    if (canDelete && !_checkfilePath2srcAssetPath.ContainsKey(realPath))
                    {
                        XFileTools.Delete(fullPath);
                    }
                }
            });

            //处理无效输出文件
            string outputFolderPath = AssetProcesserConfiger.GetInstance().GetProcessSaveFolderPath(_progresersName);

            XFolderTools.TraverseFolder(outputFolderPath, (fullPath) =>
            {
                string realPath = XPathTools.GetRelativePath(fullPath);

                string checkKey1 = Path.GetFileNameWithoutExtension(fullPath);
                string checkKey2 = XStringTools.SplitPathKey(fullPath);
                //但凡在名字上有点关系都移除,多重key检测
                if (!_processPath2srcAssetPath.ContainsKey(checkKey1) && !_processPath2srcAssetPath.ContainsKey(checkKey2) && !_processPath2srcAssetPath.ContainsKey(realPath))
                {
                    XFolderTools.DeleteDirectory(fullPath, true);
                }
            });

            XFolderTools.TraverseFiles(outputFolderPath, (fullPath) =>
            {
                string exName = Path.GetExtension(fullPath).ToLower();
                if (exName.Contains("meta"))
                {
                    return;
                }

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

                string checkKey1 = Path.GetFileNameWithoutExtension(fullPath);
                string checkKey2 = XStringTools.SplitPathKey(fullPath);
                //但凡在名字上有点关系都移除,多重key检测
                if (!_processPath2srcAssetPath.ContainsKey(checkKey1) && !_processPath2srcAssetPath.ContainsKey(checkKey2) && !_processPath2srcAssetPath.ContainsKey(realPath))
                {
                    XFileTools.Delete(fullPath);
                }
            });


            OnEnd();
        }
Exemple #5
0
 protected string GetSaveFolderPath()
 {
     __outputPath = __outputPath ?? AssetProcesserConfiger.GetInstance().GetProcessSaveFolderPath(_progresersName);
     return(__outputPath);
 }