public static void CheckAllMaterials() { CCheckTools.ClearLogList(); countStr.Clear(); repeatStr.Clear(); string[] files = Directory.GetFiles(CPath.AssetsApp, "*.*", SearchOption.AllDirectories); int fileCount = files.Length; int curIndex = 0; foreach (string f in files) { CCheckTools.DisplayProgressBar("处理中", f, curIndex / (float)fileCount); curIndex++; CheckMaterials(f); } foreach (string s in countStr) { CCheckTools.AddErrorInfo(s); } foreach (string s in repeatStr) { CCheckTools.AddErrorInfo(s); } CCheckTools.ClearProgressBar(); CCheckTools.LogAll(); CCheckTools.WriteAllInfoToFile(fileName, notice1); }
//根据路径检查triangles private static void CheckSceneTris(string path) { if (!File.Exists(path) || !path.EndsWith(".unity")) { return; } detailInfo = ""; path = path.Replace('\\', '/'); Scene scene = EditorSceneManager.OpenScene(path, OpenSceneMode.Single); int totalcount = 0; foreach (GameObject root in scene.GetRootGameObjects()) { totalcount += GetChildTris(root); } path = path.Substring(0, path.Length - ".unity".Length); if (totalcount <= 20000) { CCheckTools.AddLogInfo("场景“" + path + "”三角面总数:" + totalcount); if (!string.IsNullOrEmpty(detailInfo)) { detailInfo.Remove(detailInfo.Length - 1, 1); CCheckTools.AddLogInfo(detailInfo); } } else if (totalcount > 20000 && totalcount <= 100000) { CCheckTools.AddWarningInfo("场景“" + path + "”三角面总数:" + totalcount); if (!string.IsNullOrEmpty(detailInfo)) { detailInfo.Remove(detailInfo.Length - 1, 1); CCheckTools.AddWarningInfo(detailInfo); } } else if (totalcount > 100000) { CCheckTools.AddErrorInfo("场景“" + path + "”三角面总数:" + totalcount); if (!string.IsNullOrEmpty(detailInfo)) { detailInfo.Remove(detailInfo.Length - 1, 1); CCheckTools.AddErrorInfo(detailInfo); } } }
private static void CheckCharacterBones(string path) { if (!File.Exists(path) || !path.EndsWith(".FBX")) { return; } path = path.Replace('\\', '/'); if (Ignore(path)) { return; } GameObject rootGO = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path) as GameObject; if (null == rootGO) { return; } path = path.Substring(0, path.Length - ".FBX".Length); int totalCount = GetBonesCountByRoot(rootGO); if (path.EndsWith("_H")) { if (totalCount > 100) { CCheckTools.AddErrorInfo(path + "->count:" + totalCount); } else { CCheckTools.AddLogInfo(path + "->count:" + totalCount); } } else { if (totalCount > 50) { CCheckTools.AddErrorInfo(path + "->count:" + totalCount); } else { CCheckTools.AddLogInfo(path + "->count:" + totalCount); } } }
public static void CheckSelectedMaterials() { countStr.Clear(); repeatStr.Clear(); CCheckTools.ClearLogList(); int curIndex = 0; int fileCount; string[] filePath = null; string defaultPath = ""; CCheckTools.GetSelectedFilePath(ref filePath, ref defaultPath); if (filePath != null && filePath.Length > 0) { fileCount = filePath.Length; foreach (string s in filePath) { curIndex++; CCheckTools.DisplayProgressBar("检查中", s, curIndex / (float)fileCount); CheckMaterials(s); } CCheckTools.ClearProgressBar(); } else if (!string.IsNullOrEmpty(defaultPath)) { CheckMaterials(defaultPath); } else { Debug.LogError("未选择任何文件"); } foreach (string s in countStr) { CCheckTools.AddErrorInfo(s); } foreach (string s in repeatStr) { CCheckTools.AddErrorInfo(s); } CCheckTools.LogAll(); CCheckTools.WriteAllInfoToFile(fileName, notice2); }
private static void CheckImageSize(string path) { if (!File.Exists(path) || !path.EndsWith(".png") && !path.EndsWith(".psd") && !path.EndsWith(".tga")) { return; } path = path.Replace('\\', '/'); UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path); if (null == obj) { return; } Texture tex = obj as Texture; if (null != tex) { if (tex.width > MaxSize || tex.height > MaxSize) { CCheckTools.AddErrorInfo(path + ":" + tex.width + "*" + tex.height); } else if (tex.width > WarningSize || tex.height > WarningSize) { CCheckTools.AddWarningInfo(path + ":" + tex.width + "*" + tex.height); } if (path.Contains(mSceneFlag)) { int idx = path.IndexOf(mSceneFlag) + mSceneFlag.Length; path = path.Substring(idx); string[] pathArr = path.Split('/'); if (pathArr.Length > 0) { path = pathArr[0]; } string sceneName = path; ImageInfo imgInfo = new ImageInfo(sceneName, tex.name, tex.height, tex.width); mImageList.Add(imgInfo); } } }