Example #1
0
        // 删除重复的图片,并将重新修改prefab中的引用
        public static void DeleteRepeatSprites(bool useMd5 = false)
        {
            collectAllPngFiles();

            for (int i = 0; i < allPngFiles.Count; i++)
            {
                for (int j = i + 1; j < allPngFiles.Count; j++)
                {
                    string file           = allPngFiles[i];
                    string fileToBeDelete = allPngFiles[j];
                    if (file != fileToBeDelete)
                    {
                        bool same = false;
                        if (useMd5)
                        {
                            same = IsSameSpriteMd5File(file, fileToBeDelete);
                        }
                        else
                        {
                            //same = IsSameSpriteFile(file, fileToBeDelete);
                            same = PngUtil.IsSamePng(file, fileToBeDelete);
                        }
                        if (same)
                        {
                            resetPrefabSpite(file, fileToBeDelete);
                            File.Delete(fileToBeDelete);
                        }
                    }
                }
            }
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
Example #2
0
        public static void DeleteCurrentPsdRepeatSprites(string assetPath, bool useMd5 = false)
        {
            string currentPath = Path.Combine(texturePath, assetPath);

            if (!Directory.Exists(currentPath))
            {
                return;
            }
            string[] files = Directory.GetFiles(currentPath, "*.png");
            for (int j = 0; j < files.Length; j++)
            {
                files[j] = files[j].Replace("\\", "/");
            }
            for (int i = 0; i < files.Length; i++)
            {
                for (int j = i + 1; j < files.Length; j++)
                {
                    string file           = files[i];
                    string fileToBeDelete = files[j];
                    if (file != fileToBeDelete)
                    {
                        bool same = false;
                        if (useMd5)
                        {
                            same = IsSameSpriteMd5File(file, fileToBeDelete);
                        }
                        else
                        {
                            //same = IsSameSpriteFile(file, fileToBeDelete);
                            same = PngUtil.IsSamePng(file, fileToBeDelete);
                        }
                        if (same)
                        {
                            resetPrefabSpite(file, fileToBeDelete);
                            File.Delete(fileToBeDelete);
                        }
                    }
                }
            }
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }