? ? [MenuItem("工具箱/获取选中的物体的面数")] ? ? static void LogMeshF() ? ? { ? ? ? ? List<MeshFilter> mesh = new List<MeshFilter>(); ? ? ? ? GameObject[] gameObjects = Selection.gameObjects; ? ? ? ? for (int i = 0; i < gameObjects.Length; i++) ? ? ? ? { ? ? ? ? ? ? MeshFilter[] meshFilters= gameObjects[i].GetComponentsInChildren<MeshFilter>(); ? ? ? ? ? ? for (int j = 0; j < meshFilters.Length; j++) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (!mesh.Contains( meshFilters[j])) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? mesh.Add(meshFilters[j]); ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? } ? ? ? ? }
? ? ? ? int 顶点数=0; ? ? ? ? int 三角面数=0; ? ? ? ? for (int i = 0; i < mesh.Count; i++) ? ? ? ? { ? ? ? ? ? ? 顶点数 += mesh[i].sharedMesh.vertexCount; ? ? ? ? ? ? 三角面数 += mesh[i].sharedMesh.triangles.Length/3;
? ? ? ? } ? ? ? ? Debug.Log("顶点数:"+ 顶点数 + "_三角面数:"+三角面数); ? ? }
|