private static void CheckSceneLights(string path) { if (!File.Exists(path) || !path.EndsWith(".unity")) { return; } mode_realTime = 0; mode_baked = 0; mode_mixed = 0; 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); CCheckTools.AddLogInfo("场景“" + path + "”灯光总数:" + totalcount + "(Baked:" + mode_baked + " RealTime:" + mode_realTime + " Mixed:" + mode_mixed + ")"); if (string.IsNullOrEmpty(detailInfo)) { CCheckTools.AddLogInfo(detailInfo); } }
//根据路径检查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); } } }
// 工具基本不使用,先注释掉菜单 //[MenuItem("Assets/程序/检查工具/检查选中目录下包含的文件类型", false, 02010041)] //[MenuItem("程序/检查工具/检查选中目录下包含的文件类型", false, 02010041)] public static void CheckFileType() { CCheckTools.ClearLogList(); int fileCount; int curIndex = 0; object[] objArray = Selection.GetFiltered(typeof(DefaultAsset), SelectionMode.Assets); if (null == objArray || objArray.Length == 0) { Debug.LogError("没有选中任何文件夹"); return; } string path = AssetDatabase.GetAssetPath(objArray[0] as Object); string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); fileCount = files.Length; List <string> typeList = new List <string>(); foreach (string fp in files) { CCheckTools.DisplayProgressBar("检查中", fp, curIndex / (float)fileCount); curIndex++; if (fp.IndexOf('.') < 0) { continue; } string type = fp.Split('.')[fp.Split('.').Length - 1]; if (type.IndexOf('/') >= 0 || type.IndexOf('\\') >= 0) { continue; //排除xxx.xxx/yyy文件 } if (!typeList.Exists(s => s.Equals(type))) { typeList.Add(type); } } foreach (string s in typeList) { CCheckTools.AddLogInfo(s); } CCheckTools.LogAll(); CCheckTools.WriteAllInfoToFile("文件类型", "", CCheckTools.EFileType.txt); CCheckTools.ClearProgressBar(); }
private static void CheckFile(string path) { if (!File.Exists(path) || path.EndsWith("meta")) { return; } path = path.Replace('\\', '/'); string[] temp = path.Split('/'); string name = temp[temp.Length - 1]; foreach (char c in name) { if (c.Equals(' ')) { CCheckTools.AddLogInfo(path); break; } } }
private static void CheckCharacterTris(string path) { if (!File.Exists(path) || !path.EndsWith(".FBX")) { return; } detailInfo = ""; path = path.Replace('\\', '/'); if (Ignore(path)) { return; } GameObject rootGO = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path) as GameObject; path = path.Substring(0, path.Length - ".FBX".Length); CCheckTools.AddLogInfo("模型“" + path + "”三角面总数:" + GetChildTris(rootGO)); if (!string.IsNullOrEmpty(detailInfo)) { CCheckTools.AddLogInfo(detailInfo); } }
public static void CheckColorByRoot(Transform root) { if (root == null) { return; } MeshFilter mf = root.GetComponent <MeshFilter>(); SkinnedMeshRenderer smr = root.GetComponent <SkinnedMeshRenderer>(); if (mf != null && mf.sharedMesh != null) { if (mf.sharedMesh.colors.Length > 0 || mf.sharedMesh.colors32.Length > 0) { string logStr = CCheckTools.GetCompletePath(root); CCheckTools.AddLogInfo(logStr); } } for (int i = 0; i < root.transform.childCount; i++) { CheckColorByRoot(root.transform.GetChild(i)); } }
public static void CheckUVByRoot(Transform root) { if (root == null) { return; } MeshFilter mf = root.GetComponent <MeshFilter>(); SkinnedMeshRenderer smr = root.GetComponent <SkinnedMeshRenderer>(); int count = 0; if (mf != null && mf.sharedMesh != null) { if (mf.sharedMesh.uv.Length > 0) { count++; } if (mf.sharedMesh.uv2.Length > 0) { count++; } if (mf.sharedMesh.uv3.Length > 0) { count++; } if (mf.sharedMesh.uv4.Length > 0) { count++; } if (mf.sharedMesh.uv5.Length > 0) { count++; } if (mf.sharedMesh.uv6.Length > 0) { count++; } if (mf.sharedMesh.uv7.Length > 0) { count++; } if (mf.sharedMesh.uv8.Length > 0) { count++; } } if (smr != null && smr.sharedMesh != null) { if (smr.sharedMesh.uv.Length > 0) { count++; } if (smr.sharedMesh.uv2.Length > 0) { count++; } if (smr.sharedMesh.uv3.Length > 0) { count++; } if (smr.sharedMesh.uv4.Length > 0) { count++; } if (smr.sharedMesh.uv5.Length > 0) { count++; } if (smr.sharedMesh.uv6.Length > 0) { count++; } if (smr.sharedMesh.uv7.Length > 0) { count++; } if (smr.sharedMesh.uv8.Length > 0) { count++; } } if (count >= 2) { string logStr = CCheckTools.GetCompletePath(root); CCheckTools.AddLogInfo(logStr + ":uv Count=" + count); } for (int i = 0; i < root.transform.childCount; i++) { CheckUVByRoot(root.transform.GetChild(i)); } }