public void PostCheckResourceByType(UnityEngine.Object assetObj, H3DAssetChecker.ResouceType resType)
    {
        if (H3DAssetCheckerConfig.GetInstance().isAssetCheckerOff)
        {
            return;
        }

        bool firstImport = !H3DAssetCheckerFramework.HasAssetImportMark(assetImporter);

        if (firstImport)
        {
            H3DAssetCheckerFramework.MarkAssetImporterAsAlreadyImported(assetImporter);
        }

        bool needImport  = false;
        var  checkerList = H3DAssetCheckerFramework.GetInstance().GetAssetCheckerList(resType);

        foreach (var checker in checkerList)
        {
            if (H3DAssetCheckerUtil.IsPathInclude(assetImporter.assetPath, checker))
            {
                checker.PostCheck(assetObj, assetImporter, assetImporter.assetPath, firstImport, ref needImport);
            }
        }
    }
    public void CheckResourceByType(H3DAssetChecker.ResouceType resType)
    {
        if (H3DAssetCheckerConfig.GetInstance().isAssetCheckerOff)
        {
            return;
        }

        bool firstImport = !H3DAssetCheckerFramework.HasAssetImportMark(assetImporter);
        bool needImport  = false;
        var  checkerList = H3DAssetCheckerFramework.GetInstance().GetAssetCheckerList(resType);

        foreach (var checker in checkerList)
        {
            if (H3DAssetCheckerUtil.IsPathInclude(assetImporter.assetPath, checker))
            {
                checker.Check(null, assetImporter, assetImporter.assetPath, firstImport, ref needImport);
            }
        }
    }
Example #3
0
    //对 "Assets/" 目录下的所有资源进行检查
    public void TotalCheck()
    {
        if (H3DAssetCheckerConfig.GetInstance().isAssetCheckerOff)
        {
            return;
        }


        var pathCheckerList  = H3DAssetCheckerFramework.GetInstance().GetAssetPathCheckerList();
        var assetCheckerList = H3DAssetCheckerFramework.GetInstance().GetAssetCheckerList(H3DAssetChecker.ResouceType.ALL);


        var assetPaths = AssetDatabase.GetAllAssetPaths();

        foreach (var path in assetPaths)
        {
            if (ResourceManageToolUtility.PathIsFolder(path))
            {
                continue;
            }

            UnityEngine.Object          asset   = AssetDatabase.LoadAssetAtPath(path, typeof(object));
            H3DAssetChecker.ResouceType resType = H3DAssetChecker.QueryAssetResType(asset);
            var  assetImporter = AssetImporter.GetAtPath(path);
            bool needImport    = false;
            bool firstImport   = !HasAssetImportMark(assetImporter);

            if (firstImport)
            {//若为第一次导入则加入标记
                MarkAssetImporterAsAlreadyImported(assetImporter);
                needImport = true;
            }


            foreach (var checker in pathCheckerList)
            {
                if (H3DAssetCheckerUtil.IsPathInclude(path, checker))
                {
                    checker.Check(asset, assetImporter, path, firstImport, ref needImport);
                }
            }

            foreach (var checker in assetCheckerList)
            {
                if (
                    checker.ResType == resType &&
                    H3DAssetCheckerUtil.IsPathInclude(path, checker)
                    )
                {//使用符合资源类型的checker进行检查
                    checker.Check(asset, assetImporter, path, firstImport, ref needImport);
                    checker.PostCheck(asset, assetImporter, path, firstImport, ref needImport);
                }
            }

            if (needImport)
            {
                AssetDatabase.ImportAsset(path);
            }
        }

        AssetDatabase.Refresh();
    }
Example #4
0
 static void GenerateProjectConfig()
 {
     H3DAssetCheckerConfig.GetInstance().GenerateProjectConfig();
 }