public static AnalyzeFileInfo Generate(Object obj) { AnalyzeFileInfo info = new AnalyzeFileInfo(); info.obj = obj; info.type = obj.GetType(); info.path = AssetDatabase.GetAssetPath(obj); Dictionary <Object, SerializedObject> dict = AnalyzeFileAsset.AnalyzeObjectReference(obj); foreach (var kvp in dict) { AnalyzeObjectInfo item = new AnalyzeObjectInfo(); item.obj = kvp.Key; item.type = item.obj.GetType(); item.path = AssetDatabase.GetAssetPath(item.obj); item.guid = AssetDatabase.AssetPathToGUID(item.path); item.propertys = AnalyzeFileAsset.AnalyzeObject(kvp.Key, kvp.Value); info.Add(item); } GameObject go = obj as GameObject; if (go != null) { SkinnedMeshRenderer[] skinnedMeshRenderers = go.GetComponentsInChildren <SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer item in skinnedMeshRenderers) { Mesh mesh = item.sharedMesh; if (mesh != null) { info.TotalTriangleCount += (int)(mesh.triangles.Length / 3f); info.TotalVertexCount += mesh.vertexCount; } info.BonesCount += item.bones.Length; } MeshFilter[] meshFilters = go.GetComponentsInChildren <MeshFilter>(true); foreach (MeshFilter item in meshFilters) { Mesh mesh = item.sharedMesh; if (mesh != null) { info.TotalTriangleCount += (int)(mesh.triangles.Length / 3f); info.TotalVertexCount += mesh.vertexCount; } } ParticleSystem[] ParticleSystem = go.GetComponentsInChildren <ParticleSystem>(true); foreach (ParticleSystem particleSystem in ParticleSystem) { info.TotalForecastParticleCount += particleSystem.GetForecastParticleCount(); info.TotalForecastTrianglesCount += particleSystem.GetForecastTrianglesCount(); } } return(info); }
public static void AnalyzeMenu() { AnalyzeFileInfo info = AnalyzeFileAsset.Generate(Selection.activeObject); AnalyzeFileInfoWindow.Open(info); }