少年修仙传客户端基础资源
dabaoji
2025-06-09 8ee0256378cbf5dbc9d76ed10b60b65a844ef4dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
 
public class FBXCheck
{
 
    static List<string> logs = new List<string>();
 
 
    [MenuItem("Assets/角色、NPC 模型检查")]
    public static void LoadMesh()
    {
        var assets = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
 
        var total = assets.Length;
        var index = 0;
 
        var meshCount = 0;
        var normalCount = 0;
        var errorCount = 0;
 
        logs.Clear();
        logs.Add(StringUtility.Contact("序号", "\t", "资源名", "\t", "顶点数", "\t", "三角面"));
 
        try
        {
            foreach (var asset in assets)
            {
                var assetPath = AssetDatabase.GetAssetPath(asset);
                if (!assetPath.Contains("@"))
                {
                    var mesh = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Mesh));
                    if (mesh != null)
                    {
                        var count = ((Mesh)mesh).vertices.Length;
                        var triangles = ((Mesh)mesh).triangles.Length / 3;
 
                        var countStandard = 2500;
                        var trianglesStandard = 2600;
 
                        if (mesh.name.Contains("M") || mesh.name.Contains("N"))
                        {
                            countStandard = 2000;
                            trianglesStandard = 2000;
                        }
 
                        if (count > countStandard || triangles > trianglesStandard)
                        {
                            Debug.LogErrorFormat("{0}文件-->:顶点数:{1},三角面数:{2}", assetPath, count, triangles);
                            errorCount++;
                        }
                        else
                        {
                            Debug.LogFormat("{0}文件-->:顶点数:{1},三角面数:{2}", assetPath, count, triangles);
                            normalCount++;
                        }
 
                        logs.Add(StringUtility.Contact(logs.Count, "\t", assetPath, "\t", count, "\t", triangles));
                        meshCount++;
                    }
                }
 
                index++;
 
                EditorUtility.DisplayProgressBar("检查Mesh文件", StringUtility.Contact("检查资源文件:", asset.name, "(", index, "/", total, ")"), (float)index / total);
            }
 
            Debug.LogFormat("检查Mesh文件结束,共检查{0}个Mesh文件,其中{1}个文件正常,{2}个文件疑似异常", meshCount, normalCount, errorCount);
        }
        catch (Exception ex)
        {
            Debug.LogError(ex);
        }
        finally
        {
            File.WriteAllLines(Application.dataPath + "/FbxCheckResult.txt", logs.ToArray());
            EditorUtility.ClearProgressBar();
        }
 
    }
 
}