少年修仙传客户端基础资源
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEditor;
 
public class IconRepetitionCheck : MonoBehaviour
{
    static string rootPath = Application.dataPath + "/ResourcesOut/UI/Sprite";
    static string spriteRelativePath = "Assets/ResourcesOut/UI/Sprite/";
    static Dictionary<long, List<string>> referenceResourceSizeAndNames = new Dictionary<long, List<string>>();
 
    [MenuItem("程序/Sprite/Sprite重复性检查")]
    public static void CheckRepetition()
    {
        referenceResourceSizeAndNames.Clear();
        var allFiles = new DirectoryInfo(rootPath).GetFiles("*.png", SearchOption.AllDirectories);
        for (int i = 0; i < allFiles.Length; i++)
        {
            var fileInfo = allFiles[i];
            var size = fileInfo.Length;
            var name = fileInfo.Name;
 
            List<string> names;
            if (referenceResourceSizeAndNames.ContainsKey(size))
            {
                names = referenceResourceSizeAndNames[size];
            }
            else
            {
                referenceResourceSizeAndNames[size] = names = new List<string>();
            }
 
            names.Add(name);
        }
 
        foreach (var names in referenceResourceSizeAndNames.Values)
        {
            if (names.Count > 1)
            {
                Debug.LogFormat("疑是重复图片资源,请检查:{0}", string.Join(";", names.ToArray()));
            }
        }
    }
 
}