Ejemplo n.º 1
0
        public static CheckerResultInfo ReadCheckerResultInfo()
        {
            if (checkerResultInfo == null)
            {
                checkerResultInfo = ReadFromJson <CheckerResultInfo>(CHECKER_RESULT_INFO_PATH);
            }

            return(checkerResultInfo);
        }
Ejemplo n.º 2
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            List <CheckerFileInfo> checkerFiles = CheckerUtility.ReadCheckerFileInfos();
            CheckerResultInfo      resultInfo   = CheckerUtility.ReadCheckerResultInfo();

            if (importedAssets != null && importedAssets.Length > 0)
            {
                foreach (var assetPath in importedAssets)
                {
                    if (AssetDatabase.IsValidFolder(assetPath) && !CheckerUtility.ReadSetting().isFolderAsAsset)
                    {
                        continue;
                    }

                    CheckerFileInfo cfi = checkerFiles.FirstOrDefault((cFileInfo) =>
                    {
                        return(cFileInfo.checker.enable && cFileInfo.checker.IsMatch(assetPath));
                    });

                    if (cfi == null)
                    {
                        resultInfo.AddPassedResult(assetPath);
                    }
                    else
                    {
                        Checker checker   = cfi.checker;
                        int     errorCode = 0;
                        if (checker.DoAnalyse(assetPath, ref errorCode))
                        {
                            checker.DoOperate(assetPath);

                            resultInfo.RemoveAsset(assetPath);
                        }
                        else
                        {
                            resultInfo.AddFailedResult(assetPath, errorCode);
                        }
                    }
                }
            }

            if (deletedAssets != null && deletedAssets.Length > 0)
            {
                foreach (var assetPath in deletedAssets)
                {
                    resultInfo.RemoveAsset(assetPath);
                }
            }

            CheckerUtility.SaveCheckerResultInfo();
        }