static void UpdateTreeView() { TreeViewCtrl treeView = s_root.FindControl("_MainTreeView") as TreeViewCtrl; if (treeView == null) { return; } treeView.Clear(); string[] allAssetPaths = ResourceManageToolUtility.GetAllAssetPaths(); foreach (var path in allAssetPaths) { if (ResourceManageToolUtility.PathIsFolder(path)) { AddAssetToResourceTreeView(path); } } }
public bool IsPathContain(string path) { if (ResourceManageConfig.GetInstance().Paths.Count == 0) { //只有Assets下的资源可被包含 if (path.IndexOf("Assets") == 0) { return(true); } return(false); } foreach (var p in ResourceManageConfig.GetInstance().Paths) { if (0 == path.IndexOf(p)) { return(true); } } //此时当前路径不完全包含待扫描路径 //如果当前路径为文件夹,则看其是否 //在待扫描路径中出现 if (ResourceManageToolUtility.PathIsFolder(path)) { foreach (var p in ResourceManageConfig.GetInstance().Paths) { if (0 == p.IndexOf(path)) { return(true); } } } return(false); }
//对 "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(); }