75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
namespace BFEditor.Resource
|
|
{
|
|
public class MeshTool
|
|
{
|
|
public static List<string> checkPath = new List<string>(){
|
|
"assets/arts/effects/",
|
|
"assets/arts/models/characters/",
|
|
"assets/arts/models/maincity/",
|
|
"assets/arts/models/weapon/",
|
|
};
|
|
|
|
public static Dictionary<string, Dictionary<string, int>> results = new Dictionary<string, Dictionary<string, int>>();
|
|
|
|
public static bool CheckedOver = false;
|
|
|
|
public static void Clear()
|
|
{
|
|
results.Clear();
|
|
}
|
|
|
|
public static void Check()
|
|
{
|
|
results.Clear();
|
|
CheckedOver = false;
|
|
List<string> allFbxPath = new List<string>();
|
|
foreach(string path in checkPath)
|
|
{
|
|
string[] directories = Directory.GetDirectories(path);
|
|
foreach(string dPath in directories)
|
|
{
|
|
string[] fbxFiles = Directory.GetFiles(dPath, "*.FBX");
|
|
for(int i = 0; i < fbxFiles.Length; i ++)
|
|
{
|
|
allFbxPath.Add(fbxFiles[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach(string path in allFbxPath)
|
|
{
|
|
GameObject go = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
|
MeshFilter[] meshFilters= go.GetComponentsInChildren<MeshFilter>();
|
|
List<MeshFilter> mesh = new List<MeshFilter>();
|
|
for (int j = 0; j < meshFilters.Length; j++)
|
|
{
|
|
if (!mesh.Contains( meshFilters[j]))
|
|
{
|
|
mesh.Add(meshFilters[j]);
|
|
}
|
|
}
|
|
int vertexCount=0;
|
|
int triangles=0;
|
|
for (int i = 0; i < mesh.Count; i++)
|
|
{
|
|
vertexCount += mesh[i].sharedMesh.vertexCount;
|
|
triangles += mesh[i].sharedMesh.triangles.Length/3;
|
|
|
|
}
|
|
results[path] = new Dictionary<string, int>();
|
|
results[path].Add("vertexCount", vertexCount);
|
|
results[path].Add("triangles", triangles);
|
|
}
|
|
|
|
CheckedOver = true;
|
|
}
|
|
}
|
|
}
|