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())); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
} 
 |