//根据路径检查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 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); } } }